mirror of
https://github.com/Noratrieb/mono-fmt.git
synced 2026-01-16 00:05:05 +01:00
wow cool $crate hack thank you nemo
This commit is contained in:
parent
20befd0a8f
commit
5b22878e81
3 changed files with 49 additions and 29 deletions
|
|
@ -50,17 +50,17 @@ impl Arguments for Str {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct DebugArg<T>(pub T);
|
||||
pub struct DebugArg<T, O>(pub T, pub PhantomData<O>);
|
||||
|
||||
impl<T: Debug> Arguments for DebugArg<T> {
|
||||
impl<T: Debug, OutOpt> Arguments for DebugArg<T, OutOpt> {
|
||||
fn fmt<W: Write, O: FmtOpts>(&self, f: &mut Formatter<W, O>) -> Result {
|
||||
Debug::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DisplayArg<T>(pub T);
|
||||
pub struct DisplayArg<T, O>(pub T, pub PhantomData<O>);
|
||||
|
||||
impl<T: Display> Arguments for DisplayArg<T> {
|
||||
impl<T: Display, OutOpt> Arguments for DisplayArg<T, OutOpt> {
|
||||
fn fmt<W: Write, O: FmtOpts>(&self, f: &mut Formatter<W, O>) -> Result {
|
||||
Display::fmt(&self.0, f)
|
||||
}
|
||||
|
|
|
|||
16
src/lib.rs
16
src/lib.rs
|
|
@ -1,13 +1,18 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
// for the test macro expansion
|
||||
extern crate self as mono_fmt;
|
||||
|
||||
mod args;
|
||||
mod opts;
|
||||
mod write;
|
||||
|
||||
pub use mono_fmt_macro::format_args;
|
||||
#[doc(hidden)]
|
||||
pub use mono_fmt_macro::__format_args;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! format_args {
|
||||
($($tt:tt)*) => {
|
||||
$crate::__format_args!($crate $($tt)*)
|
||||
};
|
||||
}
|
||||
|
||||
pub use crate::args::Arguments;
|
||||
pub use crate::opts::FmtOpts;
|
||||
|
|
@ -137,7 +142,6 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn f() {
|
||||
crate::format!("uwu, {f:_<?}", "what");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue