[−][src]Struct codespan::ByteOffset
A byte offset in a source file
Implementations
impl ByteOffset
[src]
pub fn from_char_len(ch: char) -> ByteOffset
[src]
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);
pub fn from_str_len(value: &str) -> ByteOffset
[src]
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);
pub const fn to_usize(self) -> usize
[src]
Convert the offset into a usize
, for use in array indexing
Trait Implementations
impl Add<ByteOffset> for ByteIndex
[src]
type Output = ByteIndex
The resulting type after applying the +
operator.
fn add(self, rhs: ByteOffset) -> ByteIndex
[src]
impl Add<ByteOffset> for ByteOffset
[src]
type Output = ByteOffset
The resulting type after applying the +
operator.
fn add(self, rhs: ByteOffset) -> ByteOffset
[src]
impl AddAssign<ByteOffset> for ByteIndex
[src]
fn add_assign(&mut self, rhs: ByteOffset)
[src]
impl AddAssign<ByteOffset> for ByteOffset
[src]
fn add_assign(&mut self, rhs: ByteOffset)
[src]
impl Clone for ByteOffset
[src]
fn clone(&self) -> ByteOffset
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ByteOffset
[src]
impl Debug for ByteOffset
[src]
impl Default for ByteOffset
[src]
fn default() -> ByteOffset
[src]
impl Display for ByteOffset
[src]
impl Eq for ByteOffset
[src]
impl From<ByteOffset> for RawOffset
[src]
fn from(offset: ByteOffset) -> RawOffset
[src]
impl From<ByteOffset> for usize
[src]
fn from(offset: ByteOffset) -> usize
[src]
impl From<i64> for ByteOffset
[src]
impl Hash for ByteOffset
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Neg for ByteOffset
[src]
type Output = ByteOffset
The resulting type after applying the -
operator.
fn neg(self) -> ByteOffset
[src]
impl Offset for ByteOffset
[src]
const ZERO: ByteOffset
[src]
impl Ord for ByteOffset
[src]
fn cmp(&self, other: &ByteOffset) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<ByteOffset> for ByteOffset
[src]
fn eq(&self, other: &ByteOffset) -> bool
[src]
fn ne(&self, other: &ByteOffset) -> bool
[src]
impl PartialOrd<ByteOffset> for ByteOffset
[src]
fn partial_cmp(&self, other: &ByteOffset) -> Option<Ordering>
[src]
fn lt(&self, other: &ByteOffset) -> bool
[src]
fn le(&self, other: &ByteOffset) -> bool
[src]
fn gt(&self, other: &ByteOffset) -> bool
[src]
fn ge(&self, other: &ByteOffset) -> bool
[src]
impl StructuralEq for ByteOffset
[src]
impl StructuralPartialEq for ByteOffset
[src]
impl Sub<ByteOffset> for ByteOffset
[src]
type Output = ByteOffset
The resulting type after applying the -
operator.
fn sub(self, rhs: ByteOffset) -> ByteOffset
[src]
impl Sub<ByteOffset> for ByteIndex
[src]
type Output = ByteIndex
The resulting type after applying the -
operator.
fn sub(self, rhs: ByteOffset) -> ByteIndex
[src]
impl SubAssign<ByteOffset> for ByteOffset
[src]
fn sub_assign(&mut self, rhs: ByteOffset)
[src]
impl SubAssign<ByteOffset> for ByteIndex
[src]
fn sub_assign(&mut self, rhs: ByteOffset)
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,