[−][src]Struct codespan::ByteOffset
A byte offset in a source file
Methods
impl ByteOffset
[src]
pub fn from_char_utf8(ch: char) -> ByteOffset
[src]
Create a byte offset from a UTF8-encoded character
use codespan::ByteOffset; assert_eq!(ByteOffset::from_char_utf8('A').to_usize(), 1); assert_eq!(ByteOffset::from_char_utf8('ß').to_usize(), 2); assert_eq!(ByteOffset::from_char_utf8('ℝ').to_usize(), 3); assert_eq!(ByteOffset::from_char_utf8('💣').to_usize(), 4);
pub fn from_str(value: &str) -> ByteOffset
[src]
Create a byte offset from a UTF- encoded string
use codespan::ByteOffset; assert_eq!(ByteOffset::from_str("A").to_usize(), 1); assert_eq!(ByteOffset::from_str("ß").to_usize(), 2); assert_eq!(ByteOffset::from_str("ℝ").to_usize(), 3); assert_eq!(ByteOffset::from_str("💣").to_usize(), 4);
pub fn to_usize(self) -> usize
[src]
Convert the offset into a usize
, for use in array indexing
Trait Implementations
impl Offset for ByteOffset
[src]
const ZERO: ByteOffset
[src]
impl Clone for ByteOffset
[src]
fn clone(&self) -> ByteOffset
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
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 Eq for ByteOffset
[src]
impl Ord for ByteOffset
[src]
fn cmp(&self, other: &ByteOffset) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Copy for ByteOffset
[src]
impl From<i64> for ByteOffset
[src]
impl Default for ByteOffset
[src]
fn default() -> 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,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Display for ByteOffset
[src]
impl Debug for ByteOffset
[src]
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 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 Neg for ByteOffset
[src]
type Output = ByteOffset
The resulting type after applying the -
operator.
fn neg(self) -> 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 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 Send for ByteOffset
impl Sync for ByteOffset
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,