[−][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][+]
impl Add<ByteOffset> for ByteOffset
[src][+]
impl AddAssign<ByteOffset> for ByteIndex
[src][+]
impl AddAssign<ByteOffset> for ByteOffset
[src][+]
impl Clone for ByteOffset
[src][+]
impl Copy for ByteOffset
[src]
impl Debug for ByteOffset
[src][+]
impl Default for ByteOffset
[src][+]
impl Display for ByteOffset
[src][+]
impl Eq for ByteOffset
[src]
impl From<ByteOffset> for RawOffset
[src][+]
impl From<ByteOffset> for usize
[src][+]
impl From<i64> for ByteOffset
[src][+]
impl Hash for ByteOffset
[src][+]
impl Neg for ByteOffset
[src][+]
impl Offset for ByteOffset
[src][+]
impl Ord for ByteOffset
[src][+]
impl PartialEq<ByteOffset> for ByteOffset
[src][+]
impl PartialOrd<ByteOffset> for ByteOffset
[src][+]
impl StructuralEq for ByteOffset
[src]
impl StructuralPartialEq for ByteOffset
[src]
impl Sub<ByteOffset> for ByteOffset
[src][+]
impl Sub<ByteOffset> for ByteIndex
[src][+]
impl SubAssign<ByteOffset> for ByteOffset
[src][+]
impl SubAssign<ByteOffset> for ByteIndex
[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,
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,
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>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,