pub(crate) struct Extent {
offset: usize,
length: usize,
sliceptr: *const u8,
slicelen: usize,
}Expand description
An extent within a given string slice.
This whole type is probably naughty and shouldn’t exist. We use it only within this crate, to remember where it was that we found parsed objects within the strings we got them from.
Fields§
§offset: usizeAt what position within the original string is this extent, in bytes?
length: usizeHow long is this extend, in bytes?
sliceptr: *const u8What was the original string?
If this doesn’t match, there’s been an error.
slicelen: usizeHow long was the original string?
If this doesn’t match, there’s been an error.
Implementations§
Source§impl Extent
impl Extent
Sourcepub(crate) fn new(haystack: &str, needle: &str) -> Option<Extent>
pub(crate) fn new(haystack: &str, needle: &str) -> Option<Extent>
Construct a new extent to represent the position of needle
within haystack.
Return None if needle is not in fact a slice of haystack.
Sourcepub(crate) fn reconstruct<'a>(&self, haystack: &'a str) -> Option<&'a str>
pub(crate) fn reconstruct<'a>(&self, haystack: &'a str) -> Option<&'a str>
Reconstruct the original needle within haystack.
Return None if we’re sure that the haystack doesn’t match the one we were originally given.
Note that it is possible for this to give a bogus result if provided a new haystack that happens to be at the same position in memory as the original one.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Extent
impl RefUnwindSafe for Extent
impl !Send for Extent
impl !Sync for Extent
impl Unpin for Extent
impl UnsafeUnpin for Extent
impl UnwindSafe for Extent
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more