Struct codespan::ByteOffset
[−]
[src]
pub struct ByteOffset(pub RawOffset);
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 Clone for ByteOffset
[src]
fn clone(&self) -> ByteOffset
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for ByteOffset
[src]
impl PartialEq for ByteOffset
[src]
fn eq(&self, __arg_0: &ByteOffset) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &ByteOffset) -> bool
[src]
This method tests for !=
.
impl Eq for ByteOffset
[src]
impl Hash for ByteOffset
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
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 PartialOrd for ByteOffset
[src]
fn partial_cmp(&self, __arg_0: &ByteOffset) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &ByteOffset) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &ByteOffset) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &ByteOffset) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &ByteOffset) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for ByteOffset
[src]
fn cmp(&self, __arg_0: &ByteOffset) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
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 Default for ByteOffset
[src]
fn default() -> ByteOffset
[src]
Returns the "default value" for a type. Read more
impl Debug for ByteOffset
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Display for ByteOffset
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl From<RawOffset> for ByteOffset
[src]
impl Offset for ByteOffset
[src]
const ZERO: ByteOffset
ZERO: ByteOffset = ByteOffset(0)
impl Add<ByteOffset> for ByteIndex
[src]
type Output = ByteIndex
The resulting type after applying the +
operator.
fn add(self, rhs: ByteOffset) -> ByteIndex
[src]
Performs the +
operation.
impl AddAssign<ByteOffset> for ByteIndex
[src]
fn add_assign(&mut self, rhs: ByteOffset)
[src]
Performs the +=
operation.
impl Neg for ByteOffset
[src]
type Output = ByteOffset
The resulting type after applying the -
operator.
fn neg(self) -> ByteOffset
[src]
Performs the unary -
operation.
impl Add<ByteOffset> for ByteOffset
[src]
type Output = ByteOffset
The resulting type after applying the +
operator.
fn add(self, rhs: ByteOffset) -> ByteOffset
[src]
Performs the +
operation.
impl AddAssign<ByteOffset> for ByteOffset
[src]
fn add_assign(&mut self, rhs: ByteOffset)
[src]
Performs the +=
operation.
impl Sub<ByteOffset> for ByteOffset
[src]
type Output = ByteOffset
The resulting type after applying the -
operator.
fn sub(self, rhs: ByteOffset) -> ByteOffset
[src]
Performs the -
operation.
impl SubAssign<ByteOffset> for ByteOffset
[src]
fn sub_assign(&mut self, rhs: ByteOffset)
[src]
Performs the -=
operation.
impl Sub<ByteOffset> for ByteIndex
[src]
type Output = ByteIndex
The resulting type after applying the -
operator.
fn sub(self, rhs: ByteOffset) -> ByteIndex
[src]
Performs the -
operation.
impl SubAssign<ByteOffset> for ByteIndex
[src]
fn sub_assign(&mut self, rhs: ByteOffset)
[src]
Performs the -=
operation.