1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
#![deny(rust_2018_compatibility)]
#![deny(rust_2018_idioms)]
#![deny(warnings)]
#[cfg(feature = "std")]
use core::convert::Infallible;
#[allow(deprecated)]
unsafe fn uninitialized<T>() -> T {
core::mem::uninitialized()
}
#[allow(non_camel_case_types)]
pub trait uWrite {
type Error;
fn write_str(&mut self, s: &str) -> Result<(), Self::Error>;
fn write_char(&mut self, c: char) -> Result<(), Self::Error> {
let mut buf: [u8; 4] = unsafe { uninitialized() };
self.write_str(c.encode_utf8(&mut buf))
}
}
#[cfg(feature = "std")]
impl uWrite for String {
type Error = Infallible;
fn write_str(&mut self, s: &str) -> Result<(), Infallible> {
self.push_str(s);
Ok(())
}
}