pub trait Content: Sized {
type Underlying: Clone + PartialEq;
// Required methods
fn get_range(&self, range: Range<usize>) -> &[Self::Underlying];
fn decode_str(src: &str) -> Cow<'_, [Self::Underlying]>;
fn encode_bytes(bytes: &[Self::Underlying]) -> Cow<'_, str>;
fn get_char_column(&self, column: usize, offset: usize) -> usize;
}
Required Associated Types§
type Underlying: Clone + PartialEq
Required Methods§
fn get_range(&self, range: Range<usize>) -> &[Self::Underlying]
Sourcefn decode_str(src: &str) -> Cow<'_, [Self::Underlying]>
fn decode_str(src: &str) -> Cow<'_, [Self::Underlying]>
Used for string replacement. We need this for indentation and deindentation.
Sourcefn encode_bytes(bytes: &[Self::Underlying]) -> Cow<'_, str>
fn encode_bytes(bytes: &[Self::Underlying]) -> Cow<'_, str>
Used for string replacement. We need this for transformation.
Sourcefn get_char_column(&self, column: usize, offset: usize) -> usize
fn get_char_column(&self, column: usize, offset: usize) -> usize
Get the character column at the given position
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Content for String
impl Content for String
Source§fn get_char_column(&self, _col: usize, offset: usize) -> usize
fn get_char_column(&self, _col: usize, offset: usize) -> usize
This is an O(n) operation. We assume the col will not be a huge number in reality. This may be problematic for special files like compressed js