ufmt-write-0.1.0/Cargo.toml.orig010064400017500001750000000007761356433742500147510ustar0000000000000000[package] authors = ["Jorge Aparicio "] categories = ["embedded", "no-std"] description = "`μfmt`'s `uWrite` trait" edition = "2018" keywords = ["Debug", "Display", "Write", "format"] license = "MIT OR Apache-2.0" name = "ufmt-write" repository = "https://github.com/japaric/ufmt" version = "0.1.0" # NOTE do NOT add an `alloc` feature before the alloc crate can be used in # no-std BINARIES [features] # NOTE do NOT turn `std` into a default feature; this is a no-std first crate std = [] ufmt-write-0.1.0/Cargo.toml0000644000000015400000000000000111720ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "ufmt-write" version = "0.1.0" authors = ["Jorge Aparicio "] description = "`μfmt`'s `uWrite` trait" keywords = ["Debug", "Display", "Write", "format"] categories = ["embedded", "no-std"] license = "MIT OR Apache-2.0" repository = "https://github.com/japaric/ufmt" [features] std = [] ufmt-write-0.1.0/src/lib.rs010064400017500001750000000030541356433742500137550ustar0000000000000000//! `μfmt`'s `uWrite` trait #![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 { core::mem::uninitialized() } /// A collection of methods that are required / used to format a message into a stream. #[allow(non_camel_case_types)] pub trait uWrite { /// The error associated to this writer type Error; /// Writes a string slice into this writer, returning whether the write succeeded. /// /// This method can only succeed if the entire string slice was successfully written, and this /// method will not return until all data has been written or an error occurs. fn write_str(&mut self, s: &str) -> Result<(), Self::Error>; /// Writes a [`char`] into this writer, returning whether the write succeeded. /// /// A single [`char`] may be encoded as more than one byte. This method can only succeed if the /// entire byte sequence was successfully written, and this method will not return until all /// data has been written or an error occurs. 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(()) } } ufmt-write-0.1.0/.cargo_vcs_info.json0000644000000001120000000000000131660ustar00{ "git": { "sha1": "f59b61d7ed3dd9d98846f9557f15b556c2959170" } }