Skip to main content

SeqMap

Struct SeqMap 

Source
pub struct SeqMap<V> { /* private fields */ }
Expand description

Insertion-order-preserving String-keyed map with a mutable get-or-insert-default accessor. Same shape as graph::OrderedMap, kept as a separate small type here because that one exposes no get_mut/entry-style API. Public for the same reason as SeqSet – appears in [ImpactWalkResult::visited].

Implementations§

Source§

impl<V> SeqMap<V>

Source

pub fn new() -> Self

Creates an empty insertion-ordered map.

Source

pub fn contains_key(&self, key: &str) -> bool

Returns whether key is present.

Source

pub fn insert(&mut self, key: String, value: V)

Inserts or replaces the value for key while preserving key order.

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &V)>

Iterates over entries in insertion order.

Examples found in repository?
examples/extension_impact.rs (line 86)
79fn truth(index: &query::GraphIndex<'_>, seed: &str) -> Result<Value, String> {
80    let query::SeedResolution::Resolved { ids, .. } = query::resolve_impact_seed(index, seed)
81    else {
82        return Err(format!("oracle seed is not uniquely resolved: {seed}"));
83    };
84    // Oracle truncation would turn valid predictions beyond a brake into false positives.
85    let walk = query::impact_walk(index, &ids, query::DEFAULT_HOPS, true, 0, 0);
86    Ok(json!({"rows": walk.visited.iter()
87        .filter(|(_, row)| row.via_count > 0 || row.ambiguous_count > 0)
88        .map(|(file, row)| json!({"file": file, "hop": row.hop, "heuristic": false}))
89        .collect::<Vec<_>>() }))
90}
Source

pub fn keys(&self) -> impl Iterator<Item = &String>

Iterates over keys in insertion order.

Trait Implementations§

Source§

impl<V: Clone> Clone for SeqMap<V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for SeqMap<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<V> Freeze for SeqMap<V>
where Vec<(String, V)>: Freeze,

§

impl<V> RefUnwindSafe for SeqMap<V>
where Vec<(String, V)>: RefUnwindSafe,

§

impl<V> Send for SeqMap<V>
where Vec<(String, V)>: Send,

§

impl<V> Sync for SeqMap<V>
where Vec<(String, V)>: Sync,

§

impl<V> Unpin for SeqMap<V>
where Vec<(String, V)>: Unpin,

§

impl<V> UnsafeUnpin for SeqMap<V>
where Vec<(String, V)>: UnsafeUnpin,

§

impl<V> UnwindSafe for SeqMap<V>
where Vec<(String, V)>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.