acceptor_std/printer/
display_printer.rs

1use core::fmt;
2
3use accepts::{Accepts, AsyncAccepts};
4
5/// Prints values using `Display` formatting.
6#[must_use = "DisplayPrinter must be used to emit output"]
7#[derive(Debug, Clone)]
8pub struct DisplayPrinter;
9
10impl<Value> Accepts<Value> for DisplayPrinter
11where
12    Value: fmt::Display,
13{
14    fn accept(&self, value: Value) {
15        println!("{value}");
16    }
17}
18
19impl<Value> AsyncAccepts<Value> for DisplayPrinter
20where
21    Value: fmt::Display + Send,
22{
23    fn accept_async<'a>(&'a self, value: Value) -> impl core::future::Future<Output = ()> + 'a
24    where
25        Value: 'a,
26    {
27        async move { println!("{value}") }
28    }
29}