Trait RetExt

Source
pub trait RetExt: Sized {
    // Provided methods
    fn discard_self(self) { ... }
    fn discard_ret(self) { ... }
}
Expand description

Extension methods for any value that explicitly discard the value and yield unit ().

The helpers make intent obvious when chaining iterator or async pipelines.

§Examples

use unit_ext::*;

(0..3).for_each(|n| n.discard_ret());
let x: Option<usize> = Some(0).discard_self().ret_some(1);

Provided Methods§

Source

fn discard_self(self)

Discards self, returning ().

Equivalent to let _ = self;.

Source

fn discard_ret(self)

Alias for discard_self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> RetExt for T