mirror of
https://github.com/Noratrieb/mono-fmt.git
synced 2026-01-16 08:15:04 +01:00
cfg
This commit is contained in:
parent
a90c1bf054
commit
6fc05446fb
7 changed files with 143 additions and 30 deletions
10
src/lib.rs
10
src/lib.rs
|
|
@ -1,5 +1,8 @@
|
|||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
mod args;
|
||||
mod formatter;
|
||||
mod opts;
|
||||
|
|
@ -19,7 +22,7 @@ pub use crate::{
|
|||
opts::FmtOpts,
|
||||
};
|
||||
|
||||
pub type Result = std::result::Result<(), Error>;
|
||||
pub type Result = core::result::Result<(), Error>;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Error;
|
||||
|
|
@ -34,6 +37,9 @@ pub trait Write {
|
|||
}
|
||||
|
||||
pub mod helpers {
|
||||
#[cfg(feature = "alloc")]
|
||||
use alloc::string::String;
|
||||
|
||||
use crate::{Arguments, Formatter, Result, Write};
|
||||
|
||||
pub fn write<W: Write, A: Arguments>(buffer: W, args: A) -> Result {
|
||||
|
|
@ -41,6 +47,7 @@ pub mod helpers {
|
|||
args.fmt(&mut fmt)
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub fn format<A: Arguments>(args: A) -> String {
|
||||
let mut string = String::new();
|
||||
write(&mut string, args).unwrap();
|
||||
|
|
@ -59,6 +66,7 @@ pub mod _private {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
#[macro_export]
|
||||
macro_rules! format {
|
||||
($($tt:tt)*) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue