[−][src]Struct json_peek::util::Span
General position information of string
let a = Span::new(1, 5); let b = Span::from(1..=5); assert_eq!(a, b);
let span = Span::new(2, 4); span.trim(1); // Equal to: Span::new(3, 3);
Fields
start: usize
end: usize
Methods
impl Span
[src]
pub const fn new(start: usize, end: usize) -> Span
[src]
pub const fn range(&self) -> RangeInclusive<usize>
[src]
Get the range of this Span
pub const fn start_point(&self) -> Span
[src]
Create a point out of the start position of this Span
pub const fn end_point(&self) -> Span
[src]
Create a point out of the end position of this Span
pub const fn is_point(&self) -> bool
[src]
Zero-width Span
is considered to be a point
pub const fn trim(&self, offset: usize) -> Span
[src]
Shrink the size of Span by some offset
from both size
Does not check for overflow
let span = Span::new(2, 4); assert_eq!(span.trim(1), Span::new(3, 3)); assert_eq!(span.trim(2), Span::new(4, 2));
You can cause integer underflow/overflow with this method if not careful.
let span = Span::new(0, 4); span.trim(5); // <- will panic!!
pub fn from_span(left: Span, right: Span) -> Span
[src]
Create Span from two other Spans This function will construct the biggest possible Span
let a = Span::new(1, 5); let b = Span::new(4, 10); assert_eq!(Span::from_span(a, b), Span::new(1, 10));
pub const fn test() -> Span
[src]
Span value for testing purpose
Trait Implementations
impl Add<Span> for Span
[src]
type Output = Span
The resulting type after applying the +
operator.
fn add(self, rhs: Span) -> Span
[src]
impl Add<usize> for Span
[src]
type Output = Span
The resulting type after applying the +
operator.
fn add(self, rhs: usize) -> Span
[src]
impl AddAssign<Span> for Span
[src]
fn add_assign(&mut self, rhs: Span)
[src]
impl AddAssign<usize> for Span
[src]
fn add_assign(&mut self, rhs: usize)
[src]
impl Clone for Span
[src]
impl Copy for Span
[src]
impl Debug for Span
[src]
impl Default for Span
[src]
impl Display for Span
[src]
impl Eq for Span
[src]
impl From<RangeInclusive<usize>> for Span
[src]
fn from(range: RangeInclusive<usize>) -> Span
[src]
impl Hash for Span
[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 PartialEq<Span> for Span
[src]
impl StructuralEq for Span
[src]
impl StructuralPartialEq for Span
[src]
impl Sub<Span> for Span
[src]
type Output = Span
The resulting type after applying the -
operator.
fn sub(self, rhs: Span) -> Span
[src]
impl Sub<usize> for Span
[src]
type Output = Span
The resulting type after applying the -
operator.
fn sub(self, rhs: usize) -> Span
[src]
impl SubAssign<usize> for Span
[src]
fn sub_assign(&mut self, rhs: usize)
[src]
Auto Trait Implementations
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
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,
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.
fn to_owned(&self) -> T
[src]
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.
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>,