pub struct Position<T> {
pub index: usize,
pub value: T,
}Expand description
Position.
This data type attaches an index to a value, indicating its position within
a sorted stream. It is primarily used in the context of Stream::sort,
which keeps an internal store of items and updates their positions as the
items entering the stream change.
Note that ordering of positions is determined by their index, and in case a tie-breaker is necessary, by the value itself.
Fields§
§index: usizeIndex in sort order.
value: TAssociated value.
Implementations§
Source§impl<T> Position<T>
impl<T> Position<T>
Sourcepub fn new(index: usize, value: T) -> Self
pub fn new(index: usize, value: T) -> Self
Creates a position.
§Examples
use zrx_stream::value::Position;
// Create position
let position = Position::new(0, "a");Sourcepub fn into_parts(self) -> (usize, T)
pub fn into_parts(self) -> (usize, T)
Returns the index and associated value, consuming the position.
§Examples
use zrx_stream::value::Position;
// Create position
let position = Position::new(0, "a");
assert_eq!(
position.into_parts(),
(0, "a"),
);Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Returns the associated value, consuming the position.
use zrx_stream::value::Position;
// Create position
let position = Position::new(0, "a");
assert_eq!(position.into_value(), "a");Trait Implementations§
Source§impl<T: Ord> Ord for Position<T>
impl<T: Ord> Ord for Position<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Position<T>
impl<T: PartialOrd> PartialOrd for Position<T>
impl<T: Eq> Eq for Position<T>
impl<T> StructuralPartialEq for Position<T>
impl<T> Value for Position<T>where
T: Value,
Auto Trait Implementations§
impl<T> Freeze for Position<T>where
T: Freeze,
impl<T> RefUnwindSafe for Position<T>where
T: RefUnwindSafe,
impl<T> Send for Position<T>where
T: Send,
impl<T> Sync for Position<T>where
T: Sync,
impl<T> Unpin for Position<T>where
T: Unpin,
impl<T> UnsafeUnpin for Position<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Position<T>where
T: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoReport<T> for Twhere
T: Value,
impl<T> IntoReport<T> for Twhere
T: Value,
Source§impl<T, E> IntoReport<T, E> for Twhere
E: Error,
impl<T, E> IntoReport<T, E> for Twhere
E: Error,
Source§fn into_report(self) -> Result<Report<T>, E>
fn into_report(self) -> Result<Report<T>, E>
Creates a report from a value T and wraps it in a result.
§Examples
use std::io::Error;
use zrx_diagnostic::report::IntoReport;
// Define function returning a value
fn f() -> impl IntoReport<i32, Error> {
42
}
// Invoke function and create report
let res = f().into_report();Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ValueExt for Twhere
T: Value,
impl<T> ValueExt for Twhere
T: Value,
Source§fn with_diagnostics<D>(self, diagnostics: D) -> Report<Self>
fn with_diagnostics<D>(self, diagnostics: D) -> Report<Self>
Adds diagnostics to the value. Read more