Struct SeqMap

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

A deterministic map that preserves insertion order.

Internally, it uses a HashMap for quick key lookups and a Vec to maintain the order of inserted key-value pairs.

Implementations§

Source§

impl<K, V> SeqMap<K, V>
where K: Eq + Hash + Clone,

Source

pub fn new() -> SeqMap<K, V>

Creates a new, empty SeqMap.

§Examples
use seq_map::SeqMap;
let map: SeqMap<String, i32> = SeqMap::new();
Source

pub fn insert(&mut self, key: K, value: V) -> Result<(), SeqMapError>

Inserts a key-value pair into the map.

Returns an error if the key already exists.

§Errors

Returns SeqMapError::KeyAlreadyExists if the key is already present.

§Examples
use seq_map::SeqMap;
let mut map = SeqMap::new();
map.insert("key".to_string(), 42).unwrap();
assert!(map.insert("key".to_string(), 43).is_err());
Source

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

Checks if the map contains a key.

Source

pub fn get_mut(&mut self, key: &K) -> Option<&mut V>

Returns a mutable reference to the value corresponding to the key.

Returns None if the key does not exist.

§Examples
use seq_map::SeqMap;
let mut map = SeqMap::new();
map.insert("key".to_string(), 42).unwrap();
if let Some(value) = map.get_mut(&"key".to_string()) {
    *value = 100;
}
assert_eq!(map[&"key".to_string()], 100);
Source

pub fn len(&self) -> usize

Returns the number of key-value pairs in the map.

§Examples
use seq_map::SeqMap;
let mut map = SeqMap::new();
assert_eq!(map.len(), 0);
map.insert("key", 42).unwrap();
assert_eq!(map.len(), 1);
Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

§Examples
use seq_map::SeqMap;
let map: SeqMap<String, i32> = SeqMap::new();
assert!(map.is_empty());
Source

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

Returns an iterator over the keys of the map in insertion order.

§Examples
use seq_map::SeqMap;
let mut map = SeqMap::new();
map.insert("a".to_string(), 1).unwrap();
map.insert("b".to_string(), 2).unwrap();
let keys: Vec<_> = map.keys().cloned().collect();
assert_eq!(keys, vec!["a", "b"]);
Source

pub fn values(&self) -> impl Iterator<Item = &V>

Returns an iterator over the values of the map in insertion order.

§Examples
use seq_map::SeqMap;
let mut map = SeqMap::new();
map.insert("a".to_string(), 1).unwrap();
map.insert("b".to_string(), 2).unwrap();
let values: Vec<_> = map.values().cloned().collect();
assert_eq!(values, vec![1, 2]);
Source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>

Source

pub fn get_index(&self, key: &K) -> Option<usize>

Source

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

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut V)>

Source

pub fn get(&self, key: &K) -> Option<&V>

Retrieves a reference to the value corresponding to the key.

This method performs a faster lookup using the internal HashMap.

For a slower but simpler lookup, see slow_get.

§Examples
use seq_map::SeqMap;
let mut map = SeqMap::new();
map.insert("key".to_string(), 42).unwrap();
assert_eq!(map.get(&"key".to_string()), Some(&42));
Source

pub fn clear(&mut self)

Removes all elements from the map

Source

pub fn remove(&mut self, key: &K) -> Option<V>

Removes a key from the map, returning the value if it existed

Source

pub fn drain(&mut self) -> impl Iterator<Item = (K, V)>

Removes all elements from the map and returns them as an iterator

Source§

impl<K, V> SeqMap<K, V>
where K: Eq + Hash + Clone,

Source

pub fn into_keys(self) -> impl Iterator<Item = K>

Source

pub fn into_values(self) -> impl Iterator<Item = V>

Trait Implementations§

Source§

impl<K, V> Clone for SeqMap<K, V>
where K: Clone, V: Clone,

Source§

fn clone(&self) -> SeqMap<K, V>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<K, V> Debug for SeqMap<K, V>
where K: Eq + Hash + Debug, V: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<K, V> Default for SeqMap<K, V>

Source§

fn default() -> SeqMap<K, V>

Creates a new, empty SeqMap.

§Examples
use seq_map::SeqMap;
let map: SeqMap<String, i32> = SeqMap::default();
Source§

impl<K, V> Display for SeqMap<K, V>
where K: Eq + Hash + Display, V: Display,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<K, V> Extend<(K, V)> for SeqMap<K, V>
where K: Eq + Hash + Clone,

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = (K, V)>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<K, V> From<&[(K, V)]> for SeqMap<K, V>
where K: Eq + Hash + Clone, V: Clone,

Source§

fn from(slice: &[(K, V)]) -> SeqMap<K, V>

Creates a SeqMap from a slice of key-value pairs.

If duplicate keys are present in the slice, the first occurrence is kept, and subsequent duplicates are ignored.

§Examples
use seq_map::SeqMap;
let pairs = vec![
    ("a".to_string(), 1),
    ("b".to_string(), 2),
];
let map: SeqMap<_, _> = SeqMap::from(&pairs[..]);
assert_eq!(map.len(), 2);
Source§

impl<K, V> FromIterator<(K, V)> for SeqMap<K, V>
where K: Hash + Eq + Clone, V: Clone,

Creates a SeqMap from an iterator of key-value pairs.

If duplicate keys are present in the iterator, the first occurrence is kept, and subsequent duplicates are silently ignored.

Source§

fn from_iter<T>(iter: T) -> SeqMap<K, V>
where T: IntoIterator<Item = (K, V)>,

Creates a value from an iterator. Read more
Source§

impl<K, V> Hash for SeqMap<K, V>
where K: Hash, V: Hash,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K, V> Index<&K> for SeqMap<K, V>
where K: Eq + Hash + Clone, V: Clone,

Source§

fn index(&self, key: &K) -> &<SeqMap<K, V> as Index<&K>>::Output

Allows accessing values using the indexing syntax (map[&key]).

§Panics

Panics if the key is not present in the map.

§Examples
use seq_map::SeqMap;
let mut map = SeqMap::new();
map.insert("key".to_string(), 42).unwrap();
assert_eq!(map[&"key".to_string()], 42);
Source§

type Output = V

The returned type after indexing.
Source§

impl<'a, K, V> IntoIterator for &'a SeqMap<K, V>
where K: Eq + Hash + Clone,

Source§

fn into_iter(self) -> <&'a SeqMap<K, V> as IntoIterator>::IntoIter

Returns an iterator over references to the key-value pairs in insertion order.

This implementation allows you to iterate over references to the keys and values without consuming the SeqMap. It’s useful for scenarios where you want to inspect the contents of the map without modifying it.

§Examples
§Iterating Over References
use seq_map::SeqMap;

let mut map = SeqMap::new();
map.insert("a".to_string(), 1).unwrap();
map.insert("b".to_string(), 2).unwrap();
map.insert("c".to_string(), 3).unwrap();

for (key, value) in &map {
    println!("{}: {}", key, value);
}
§Collecting into a Vector of References
use seq_map::SeqMap;

let mut map = SeqMap::new();
map.insert("x".to_string(), 100).unwrap();
map.insert("y".to_string(), 200).unwrap();

let entries: Vec<_> = (&map).into_iter().collect();
assert_eq!(
    entries,
    vec![
        (&"x".to_string(), &100),
        (&"y".to_string(), &200),
    ]
);
Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = Map<Iter<'a, (K, V)>, fn(&'a (K, V)) -> (&'a K, &'a V)>

Which kind of iterator are we turning this into?
Source§

impl<'a, K, V> IntoIterator for &'a mut SeqMap<K, V>
where K: Eq + Hash + Clone,

Source§

type Item = (&'a K, &'a mut V)

The type of the elements being iterated over.
Source§

type IntoIter = Map<IterMut<'a, (K, V)>, fn(&'a mut (K, V)) -> (&'a K, &'a mut V)>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a mut SeqMap<K, V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V> IntoIterator for SeqMap<K, V>
where K: Eq + Hash + Clone,

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<(K, V)>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <SeqMap<K, V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V> PartialEq for SeqMap<K, V>
where K: Eq, V: Eq,

Source§

fn eq(&self, other: &SeqMap<K, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, V> Eq for SeqMap<K, V>
where K: Eq, V: Eq,

Auto Trait Implementations§

§

impl<K, V> Freeze for SeqMap<K, V>

§

impl<K, V> RefUnwindSafe for SeqMap<K, V>

§

impl<K, V> Send for SeqMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for SeqMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for SeqMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for SeqMap<K, V>
where K: UnwindSafe, 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Paint for T
where T: ?Sized,

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more