pub trait Accepts<Value> {
// Required method
fn accept(&self, value: Value);
}Expand description
Receives a value and processes it immediately.
The trait abstracts over acceptors: objects that can be invoked with a value without returning any meaningful result. This is useful for sinks, callbacks, or visitor-like APIs where forwarding or side effects are all that is needed.
use accepts::Accepts;
struct Printer;
impl Accepts<&'static str> for Printer {
fn accept(&self, value: &'static str) {
println!("{}", value);
}
}
let printer = Printer;
printer.accept("Hello, world!");Required Methods§
Implementations on Foreign Types§
Source§impl<T: Accepts<Value> + ?Sized, Value> Accepts<Value> for Box<T>
Available on crate feature alloc only.
impl<T: Accepts<Value> + ?Sized, Value> Accepts<Value> for Box<T>
Available on crate feature
alloc only.Source§impl<T: Accepts<Value> + ?Sized, Value> Accepts<Value> for Rc<T>
Available on crate feature alloc only.
impl<T: Accepts<Value> + ?Sized, Value> Accepts<Value> for Rc<T>
Available on crate feature
alloc only.Source§impl<T: Accepts<Value> + ?Sized, Value> Accepts<Value> for Arc<T>
Available on crate feature alloc only.
impl<T: Accepts<Value> + ?Sized, Value> Accepts<Value> for Arc<T>
Available on crate feature
alloc only.