Coverage Report

Created: 2024-12-17 06:15

/rust/registry/src/index.crates.io-6f17d22bba15001f/nu-ansi-term-0.46.0/src/write.rs
Line
Count
Source (jump to first uncovered line)
1
use std::fmt;
2
use std::io;
3
4
pub trait AnyWrite {
5
    type Wstr: ?Sized;
6
    type Error;
7
8
    fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error>;
9
10
    fn write_str(&mut self, s: &Self::Wstr) -> Result<(), Self::Error>;
11
}
12
13
impl<'a> AnyWrite for dyn fmt::Write + 'a {
14
    type Wstr = str;
15
    type Error = fmt::Error;
16
17
0
    fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error> {
18
0
        fmt::Write::write_fmt(self, fmt)
19
0
    }
20
21
0
    fn write_str(&mut self, s: &Self::Wstr) -> Result<(), Self::Error> {
22
0
        fmt::Write::write_str(self, s)
23
0
    }
24
}
25
26
impl<'a> AnyWrite for dyn io::Write + 'a {
27
    type Wstr = [u8];
28
    type Error = io::Error;
29
30
0
    fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error> {
31
0
        io::Write::write_fmt(self, fmt)
32
0
    }
33
34
0
    fn write_str(&mut self, s: &Self::Wstr) -> Result<(), Self::Error> {
35
0
        io::Write::write_all(self, s)
36
0
    }
37
}