Skip to main content

MarkdownFiles

Struct MarkdownFiles 

Source
pub struct MarkdownFiles(/* private fields */);

Methods from Deref<Target = HashMap<PathBuf, MarkdownInfo>>§

Source

pub fn pin(&self) -> HashMapRef<'_, K, V, S, LocalGuard<'_>>

Returns a pinned reference to the map.

The returned reference manages a guard internally, preventing garbage collection for as long as it is held. See the crate-level documentation for details.

Source

pub fn pin_owned(&self) -> HashMapRef<'_, K, V, S, OwnedGuard<'_>>

Returns a pinned reference to the map.

Unlike HashMap::pin, the returned reference implements Send and Sync, allowing it to be held across .await points in work-stealing schedulers. This is especially useful for iterators.

The returned reference manages a guard internally, preventing garbage collection for as long as it is held. See the crate-level documentation for details.

Source

pub fn guard(&self) -> LocalGuard<'_>

Returns a guard for use with this map.

Note that holding on to a guard prevents garbage collection. See the crate-level documentation for details.

Source

pub fn owned_guard(&self) -> OwnedGuard<'_>

Returns an owned guard for use with this map.

Owned guards implement Send and Sync, allowing them to be held across .await points in work-stealing schedulers. This is especially useful for iterators.

Note that holding on to a guard prevents garbage collection. See the crate-level documentation for details.

Source

pub fn len(&self) -> usize

Returns the number of entries in the map.

§Examples
use papaya::HashMap;

let map = HashMap::new();

map.pin().insert(1, "a");
map.pin().insert(2, "b");
assert!(map.len() == 2);
Source

pub fn is_empty(&self) -> bool

Returns true if the map is empty. Otherwise returns false.

§Examples
use papaya::HashMap;

let map = HashMap::new();
assert!(map.is_empty());
map.pin().insert("a", 1);
assert!(!map.is_empty());
Source

pub fn contains_key<Q>(&self, key: &Q, guard: &impl Guard) -> bool
where Q: Equivalent<K> + Hash + ?Sized,

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use papaya::HashMap;

let map = HashMap::new();
map.pin().insert(1, "a");
assert_eq!(map.pin().contains_key(&1), true);
assert_eq!(map.pin().contains_key(&2), false);
Source

pub fn get<'g, Q>(&self, key: &Q, guard: &'g impl Guard) -> Option<&'g V>
where K: 'g, Q: Equivalent<K> + Hash + ?Sized,

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use papaya::HashMap;

let map = HashMap::new();
map.pin().insert(1, "a");
assert_eq!(map.pin().get(&1), Some(&"a"));
assert_eq!(map.pin().get(&2), None);
Source

pub fn get_key_value<'g, Q>( &self, key: &Q, guard: &'g impl Guard, ) -> Option<(&'g K, &'g V)>
where Q: Equivalent<K> + Hash + ?Sized,

Returns the key-value pair corresponding to the supplied key.

The supplied key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use papaya::HashMap;

let map = HashMap::new();
map.pin().insert(1, "a");
assert_eq!(map.pin().get_key_value(&1), Some((&1, &"a")));
assert_eq!(map.pin().get_key_value(&2), None);
Source

pub fn insert<'g>( &self, key: K, value: V, guard: &'g impl Guard, ) -> Option<&'g V>

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical. See the standard library documentation for details.

§Examples
use papaya::HashMap;

let map = HashMap::new();
assert_eq!(map.pin().insert(37, "a"), None);
assert_eq!(map.pin().is_empty(), false);

map.pin().insert(37, "b");
assert_eq!(map.pin().insert(37, "c"), Some(&"b"));
assert_eq!(map.pin().get(&37), Some(&"c"));
Source

pub fn try_insert<'g>( &self, key: K, value: V, guard: &'g impl Guard, ) -> Result<&'g V, OccupiedError<'g, V>>

Tries to insert a key-value pair into the map, and returns a reference to the value that was inserted.

If the map already had this key present, nothing is updated, and an error containing the existing value is returned.

§Examples
use papaya::HashMap;

let map = HashMap::new();
let map = map.pin();

assert_eq!(map.try_insert(37, "a").unwrap(), &"a");

let err = map.try_insert(37, "b").unwrap_err();
assert_eq!(err.current, &"a");
assert_eq!(err.not_inserted, "b");
Source

pub fn try_insert_with<'g, F>( &self, key: K, f: F, guard: &'g impl Guard, ) -> Result<&'g V, &'g V>
where F: FnOnce() -> V, K: 'g,

Tries to insert a key and value computed from a closure into the map, and returns a reference to the value that was inserted.

If the map already had this key present, nothing is updated, and the existing value is returned.

§Examples
use papaya::HashMap;

let map = HashMap::new();
let map = map.pin();

assert_eq!(map.try_insert_with(37, || "a").unwrap(), &"a");

let current = map.try_insert_with(37, || "b").unwrap_err();
assert_eq!(current, &"a");
Source

pub fn get_or_insert<'g>( &self, key: K, value: V, guard: &'g impl Guard, ) -> &'g V

Returns a reference to the value corresponding to the key, or inserts a default value.

If the given key is present, the corresponding value is returned. If it is not present, the provided value is inserted, and a reference to the newly inserted value is returned.

§Examples
use papaya::HashMap;

let map = HashMap::new();
assert_eq!(map.pin().get_or_insert("a", 3), &3);
assert_eq!(map.pin().get_or_insert("a", 6), &3);
Source

pub fn get_or_insert_with<'g, F>( &self, key: K, f: F, guard: &'g impl Guard, ) -> &'g V
where F: FnOnce() -> V, K: 'g,

Returns a reference to the value corresponding to the key, or inserts a default value computed from a closure.

If the given key is present, the corresponding value is returned. If it is not present, the value computed from f is inserted, and a reference to the newly inserted value is returned.

§Examples
use papaya::HashMap;

let map = HashMap::new();
assert_eq!(map.pin().get_or_insert_with("a", || 3), &3);
assert_eq!(map.pin().get_or_insert_with("a", || 6), &3);
Source

pub fn update<'g, F>( &self, key: K, update: F, guard: &'g impl Guard, ) -> Option<&'g V>
where F: Fn(&V) -> V, K: 'g,

Updates an existing entry atomically.

If the value for the specified key is present, the new value is computed and stored the using the provided update function, and the new value is returned. Otherwise, None is returned.

The update function is given the current value associated with the given key and returns the new value to be stored. The operation is applied atomically only if the state of the entry remains the same, meaning that it is not concurrently modified in any way. If the entry is modified, the operation is retried with the new entry, similar to a traditional compare-and-swap operation.

Note that the update function should be pure as it may be called multiple times, and the output for a given entry may be memoized across retries.

§Examples
use papaya::HashMap;

let map = HashMap::new();
map.pin().insert("a", 1);
assert_eq!(map.pin().get(&"a"), Some(&1));

map.pin().update("a", |v| v + 1);
assert_eq!(map.pin().get(&"a"), Some(&2));
Source

pub fn update_or_insert<'g, F>( &self, key: K, update: F, value: V, guard: &'g impl Guard, ) -> &'g V
where F: Fn(&V) -> V, K: 'g,

Updates an existing entry or inserts a default value.

If the value for the specified key is present, the new value is computed and stored the using the provided update function, and the new value is returned. Otherwise, the provided value is inserted into the map, and a reference to the newly inserted value is returned.

See HashMap::update for details about how atomic updates are performed.

§Examples
use papaya::HashMap;

let map = HashMap::new();
assert_eq!(*map.pin().update_or_insert("a", |i| i + 1, 0), 0);
assert_eq!(*map.pin().update_or_insert("a", |i| i + 1, 0), 1);
Source

pub fn update_or_insert_with<'g, U, F>( &self, key: K, update: U, f: F, guard: &'g impl Guard, ) -> &'g V
where F: FnOnce() -> V, U: Fn(&V) -> V, K: 'g,

Updates an existing entry or inserts a default value computed from a closure.

If the value for the specified key is present, the new value is computed and stored the using the provided update function, and the new value is returned. Otherwise, the value computed by f is inserted into the map, and a reference to the newly inserted value is returned.

See HashMap::update for details about how atomic updates are performed.

§Examples
use papaya::HashMap;

let map = HashMap::new();
assert_eq!(*map.pin().update_or_insert_with("a", |i| i + 1, || 0), 0);
assert_eq!(*map.pin().update_or_insert_with("a", |i| i + 1, || 0), 1);
Source

pub fn compute<'g, F, T>( &self, key: K, compute: F, guard: &'g impl Guard, ) -> Compute<'g, K, V, T>
where F: FnMut(Option<(&'g K, &'g V)>) -> Operation<V, T>,

Updates an entry with a compare-and-swap (CAS) function.

This method allows you to perform complex operations on the map atomically. The compute closure is given the current state of the entry and returns the operation that should be performed. The operation is applied atomically only if the state of the entry remains the same, meaning it is not concurrently modified in any way.

Note that the compute function should be pure as it may be called multiple times, and the output for a given entry may be memoized across retries.

In most cases you can avoid this method and instead use a higher-level atomic operation. See the crate-level documentation for details.

§Examples
use papaya::{HashMap, Operation, Compute};

let map = HashMap::new();
let map = map.pin();

let compute = |entry| match entry {
    // Remove the value if it is even.
    Some((_key, value)) if value % 2 == 0 => {
        Operation::Remove
    }

    // Increment the value if it is odd.
    Some((_key, value)) => {
        Operation::Insert(value + 1)
    }

    // Do nothing if the key does not exist
    None => Operation::Abort(()),
};

assert_eq!(map.compute('A', compute), Compute::Aborted(()));

map.insert('A', 1);
assert_eq!(map.compute('A', compute), Compute::Updated {
    old: (&'A', &1),
    new: (&'A', &2),
});
assert_eq!(map.compute('A', compute), Compute::Removed(&'A', &2));
Source

pub fn remove<'g, Q>(&self, key: &Q, guard: &'g impl Guard) -> Option<&'g V>
where K: 'g, Q: Equivalent<K> + Hash + ?Sized,

Removes a key from the map, returning the value at the key if the key was previously in the map.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use papaya::HashMap;

let map = HashMap::new();
map.pin().insert(1, "a");
assert_eq!(map.pin().remove(&1), Some(&"a"));
assert_eq!(map.pin().remove(&1), None);
Source

pub fn remove_entry<'g, Q>( &self, key: &Q, guard: &'g impl Guard, ) -> Option<(&'g K, &'g V)>
where K: 'g, Q: Equivalent<K> + Hash + ?Sized,

Removes a key from the map, returning the stored key and value if the key was previously in the map.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use papaya::HashMap;

let map = HashMap::new();
map.pin().insert(1, "a");
assert_eq!(map.pin().get(&1), Some(&"a"));
assert_eq!(map.pin().remove_entry(&1), Some((&1, &"a")));
assert_eq!(map.pin().remove(&1), None);
Source

pub fn remove_if<'g, Q, F>( &self, key: &Q, should_remove: F, guard: &'g impl Guard, ) -> Result<Option<(&'g K, &'g V)>, (&'g K, &'g V)>
where Q: Equivalent<K> + Hash + ?Sized, F: FnMut(&K, &V) -> bool,

Conditionally removes a key from the map based on the provided closure.

If the key is found in the map and the closure returns true given the key and its value, the key and value are returned successfully. Note that the returned entry is guaranteed to be the same entry that the closure returned true for. However, the closure returning true does not guarantee that the entry is removed in the presence of concurrent modifications.

If the key is not found in the map, Ok(None) is returned.

If the closure returns false, an error is returned containing the entry provided to the closure.

§Examples
use papaya::HashMap;

let map = HashMap::new();
map.pin().insert(1, "a");

assert_eq!(map.pin().remove_if(&1, |k, v| *v == "b"), Err((&1, &"a")));
assert_eq!(map.pin().get(&1), Some(&"a"));
assert_eq!(map.pin().remove_if(&1, |k, v| *v == "a"), Ok(Some((&1, &"a"))));
assert_eq!(map.pin().remove_if(&1, |_, _| true), Ok(None));
Source

pub fn reserve(&self, additional: usize, guard: &impl Guard)

Tries to reserve capacity for additional more elements to be inserted in the HashMap.

After calling this method, the table should be able to hold at least capacity elements before resizing. However, the capacity is an estimate, and the table may prematurely resize due to poor hash distribution. The collection may also reserve more space to avoid frequent reallocations.

§Panics

Panics if the new allocation size overflows usize.

§Examples
use papaya::HashMap;

let map: HashMap<&str, i32> = HashMap::new();
map.pin().reserve(10);
Source

pub fn clear(&self, guard: &impl Guard)

Clears the map, removing all key-value pairs.

Note that this method will block until any in-progress resizes are completed before proceeding. See the consistency section for details.

§Examples
use papaya::HashMap;

let map = HashMap::new();

map.pin().insert(1, "a");
map.pin().clear();
assert!(map.pin().is_empty());
Source

pub fn retain<F>(&self, f: F, guard: &impl Guard)
where F: FnMut(&K, &V) -> bool,

Retains only the elements specified by the predicate.

In other words, remove all pairs (k, v) for which f(&k, &v) returns false. The elements are visited in unsorted (and unspecified) order.

Note the function may be called more than once for a given key if its value is concurrently modified during removal.

Additionally, this method will block until any in-progress resizes are completed before proceeding. See the consistency section for details.

§Examples
use papaya::HashMap;

let mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x * 10)).collect();
map.pin().retain(|&k, _| k % 2 == 0);
assert_eq!(map.len(), 4);
Source

pub fn iter<'g, G>(&self, guard: &'g G) -> Iter<'g, K, V, G> ⓘ
where G: Guard,

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&K, &V).

Note that this method will block until any in-progress resizes are completed before proceeding. See the consistency section for details.

§Examples
use papaya::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for (key, val) in map.pin().iter() {
    println!("key: {key} val: {val}");
}
Source

pub fn keys<'g, G>(&self, guard: &'g G) -> Keys<'g, K, V, G> ⓘ
where G: Guard,

An iterator visiting all keys in arbitrary order. The iterator element type is &K.

Note that this method will block until any in-progress resizes are completed before proceeding. See the consistency section for details.

§Examples
use papaya::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for key in map.pin().keys() {
    println!("{key}");
}
Source

pub fn values<'g, G>(&self, guard: &'g G) -> Values<'g, K, V, G> ⓘ
where G: Guard,

An iterator visiting all values in arbitrary order. The iterator element type is &V.

Note that this method will block until any in-progress resizes are completed before proceeding. See the consistency section for details.

§Examples
use papaya::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for value in map.pin().values() {
    println!("{value}");
}

Trait Implementations§

Source§

impl Clone for MarkdownFiles

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 Deref for MarkdownFiles

Source§

type Target = HashMap<PathBuf, MarkdownInfo>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Serialize for MarkdownFiles

Serializes in url_path order rather than map order.

papaya::HashMap uses a randomly seeded RandomState, so iteration order differs between processes: two builds of the same repository produced byte-different site.json/media.json, which churns committed build/ directories and invalidates content-hash/ETag caches on a no-op rebuild. raw_path breaks ties, because distinct files can share a url_path (docs/index.md and docs.md both render at /docs/).

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> 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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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