Struct codespan::ByteOffset
source · [−]pub struct ByteOffset(pub RawOffset);
Expand description
A byte offset in a source file
Tuple Fields
0: RawOffset
Implementations
sourceimpl ByteOffset
impl ByteOffset
sourcepub fn from_char_len(ch: char) -> ByteOffset
pub fn from_char_len(ch: char) -> ByteOffset
Create a byte offset from a UTF8-encoded character
use codespan::ByteOffset;
assert_eq!(ByteOffset::from_char_len('A').to_usize(), 1);
assert_eq!(ByteOffset::from_char_len('ß').to_usize(), 2);
assert_eq!(ByteOffset::from_char_len('ℝ').to_usize(), 3);
assert_eq!(ByteOffset::from_char_len('💣').to_usize(), 4);
sourcepub fn from_str_len(value: &str) -> ByteOffset
pub fn from_str_len(value: &str) -> ByteOffset
Create a byte offset from a UTF- encoded string
use codespan::ByteOffset;
assert_eq!(ByteOffset::from_str_len("A").to_usize(), 1);
assert_eq!(ByteOffset::from_str_len("ß").to_usize(), 2);
assert_eq!(ByteOffset::from_str_len("ℝ").to_usize(), 3);
assert_eq!(ByteOffset::from_str_len("💣").to_usize(), 4);
Trait Implementations
sourceimpl Add<ByteOffset> for ByteIndex
impl Add<ByteOffset> for ByteIndex
sourceimpl Add<ByteOffset> for ByteOffset
impl Add<ByteOffset> for ByteOffset
type Output = ByteOffset
type Output = ByteOffset
The resulting type after applying the +
operator.
sourcefn add(self, rhs: ByteOffset) -> ByteOffset
fn add(self, rhs: ByteOffset) -> ByteOffset
Performs the +
operation. Read more
sourceimpl AddAssign<ByteOffset> for ByteIndex
impl AddAssign<ByteOffset> for ByteIndex
sourcefn add_assign(&mut self, rhs: ByteOffset)
fn add_assign(&mut self, rhs: ByteOffset)
Performs the +=
operation. Read more
sourceimpl AddAssign<ByteOffset> for ByteOffset
impl AddAssign<ByteOffset> for ByteOffset
sourcefn add_assign(&mut self, rhs: ByteOffset)
fn add_assign(&mut self, rhs: ByteOffset)
Performs the +=
operation. Read more
sourceimpl Clone for ByteOffset
impl Clone for ByteOffset
sourcefn clone(&self) -> ByteOffset
fn clone(&self) -> ByteOffset
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ByteOffset
impl Debug for ByteOffset
sourceimpl Default for ByteOffset
impl Default for ByteOffset
sourcefn default() -> ByteOffset
fn default() -> ByteOffset
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for ByteOffset
impl<'de> Deserialize<'de> for ByteOffset
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for ByteOffset
impl Display for ByteOffset
sourceimpl From<ByteOffset> for RawOffset
impl From<ByteOffset> for RawOffset
sourcefn from(offset: ByteOffset) -> RawOffset
fn from(offset: ByteOffset) -> RawOffset
Performs the conversion.
sourceimpl From<ByteOffset> for usize
impl From<ByteOffset> for usize
sourcefn from(offset: ByteOffset) -> usize
fn from(offset: ByteOffset) -> usize
Performs the conversion.
sourceimpl Hash for ByteOffset
impl Hash for ByteOffset
sourceimpl Neg for ByteOffset
impl Neg for ByteOffset
type Output = ByteOffset
type Output = ByteOffset
The resulting type after applying the -
operator.
sourcefn neg(self) -> ByteOffset
fn neg(self) -> ByteOffset
Performs the unary -
operation. Read more
sourceimpl Offset for ByteOffset
impl Offset for ByteOffset
const ZERO: ByteOffset
sourceimpl Ord for ByteOffset
impl Ord for ByteOffset
sourceimpl PartialEq<ByteOffset> for ByteOffset
impl PartialEq<ByteOffset> for ByteOffset
sourcefn eq(&self, other: &ByteOffset) -> bool
fn eq(&self, other: &ByteOffset) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ByteOffset) -> bool
fn ne(&self, other: &ByteOffset) -> bool
This method tests for !=
.
sourceimpl PartialOrd<ByteOffset> for ByteOffset
impl PartialOrd<ByteOffset> for ByteOffset
sourcefn partial_cmp(&self, other: &ByteOffset) -> Option<Ordering>
fn partial_cmp(&self, other: &ByteOffset) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for ByteOffset
impl Serialize for ByteOffset
sourceimpl Sub<ByteOffset> for ByteOffset
impl Sub<ByteOffset> for ByteOffset
type Output = ByteOffset
type Output = ByteOffset
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: ByteOffset) -> ByteOffset
fn sub(self, rhs: ByteOffset) -> ByteOffset
Performs the -
operation. Read more
sourceimpl Sub<ByteOffset> for ByteIndex
impl Sub<ByteOffset> for ByteIndex
sourceimpl SubAssign<ByteOffset> for ByteOffset
impl SubAssign<ByteOffset> for ByteOffset
sourcefn sub_assign(&mut self, rhs: ByteOffset)
fn sub_assign(&mut self, rhs: ByteOffset)
Performs the -=
operation. Read more
sourceimpl SubAssign<ByteOffset> for ByteIndex
impl SubAssign<ByteOffset> for ByteIndex
sourcefn sub_assign(&mut self, rhs: ByteOffset)
fn sub_assign(&mut self, rhs: ByteOffset)
Performs the -=
operation. Read more
impl Copy for ByteOffset
impl Eq for ByteOffset
impl StructuralEq for ByteOffset
impl StructuralPartialEq for ByteOffset
Auto Trait Implementations
impl RefUnwindSafe for ByteOffset
impl Send for ByteOffset
impl Sync for ByteOffset
impl Unpin for ByteOffset
impl UnwindSafe for ByteOffset
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more