pub struct Section<'a, T: Keyword> {
v: Vec<TokVal<'a, T>>,
first: Option<T>,
last: Option<T>,
}
Expand description
A Section is the result of sorting a document’s entries by keyword.
TODO: I’d rather have this be pub(crate), but I haven’t figured out how to make that work.
Fields§
§v: Vec<TokVal<'a, T>>
Map from Keyword index to TokVal
first: Option<T>
The keyword that appeared first in this section. This will
be set if v
is nonempty.
last: Option<T>
The keyword that appeared last in this section. This will
be set if v
is nonempty.
Implementations§
Source§impl<'a, T: Keyword> Section<'a, T>
impl<'a, T: Keyword> Section<'a, T>
Sourcepub(crate) fn slice(&self, t: T) -> &[Item<'a, T>]
pub(crate) fn slice(&self, t: T) -> &[Item<'a, T>]
Return all the Items for some Keyword, as a slice.
Sourcepub(crate) fn get(&self, t: T) -> Option<&Item<'a, T>>
pub(crate) fn get(&self, t: T) -> Option<&Item<'a, T>>
Return a single Item for some Keyword, if there is exactly one.
Sourcepub(crate) fn required(&self, t: T) -> Result<&Item<'a, T>>
pub(crate) fn required(&self, t: T) -> Result<&Item<'a, T>>
Return a single Item for some Keyword, giving an error if there is not exactly one.
It is usually a mistake to use this function on a Keyword that is not required.
Sourcepub(crate) fn maybe<'b>(&'b self, t: T) -> MaybeItem<'b, 'a, T>
pub(crate) fn maybe<'b>(&'b self, t: T) -> MaybeItem<'b, 'a, T>
Return a proxy MaybeItem object for some keyword. A MaybeItem is used to represent an object that might or might not be there.
Sourcepub(crate) fn first_item(&self) -> Option<&Item<'a, T>>
pub(crate) fn first_item(&self) -> Option<&Item<'a, T>>
Return the first item that was accepted for this section, or None if no items were accepted for this section.
Auto Trait Implementations§
impl<'a, T> Freeze for Section<'a, T>where
T: Freeze,
impl<'a, T> !RefUnwindSafe for Section<'a, T>
impl<'a, T> Send for Section<'a, T>where
T: Send,
impl<'a, T> !Sync for Section<'a, T>
impl<'a, T> Unpin for Section<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for Section<'a, T>where
T: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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