1#[cfg(feature = "std")]
7#[macro_export]
8macro_rules! print {
9 ($($tt:tt)*) => {
10 ::std::print!("{}", $crate::fmt(|_f| {
11 $crate::__fmt!{_f $($tt)*}
12 Ok(())
13 }))
14 };
15}
16
17#[cfg(feature = "std")]
19#[macro_export]
20macro_rules! println {
21 ($($tt:tt)*) => {
22 ::std::print!("{}", $crate::fmt(|_f| {
23 $crate::__fmt!{_f $($tt)* "\n"}
24 Ok(())
25 }))
26 };
27}
28
29#[cfg(feature = "std")]
31#[macro_export]
32macro_rules! eprint {
33 ($($tt:tt)*) => {
34 ::std::eprint!("{}", $crate::fmt(|_f| {
35 $crate::__fmt!{_f $($tt)*}
36 Ok(())
37 }))
38 };
39}
40
41#[cfg(feature = "std")]
43#[macro_export]
44macro_rules! eprintln {
45 ($($tt:tt)*) => {
46 ::std::eprint!("{}", $crate::fmt(|_f| {
47 $crate::__fmt!{_f $($tt)* "\n"}
48 Ok(())
49 }))
50 };
51}
52
53#[macro_export]
55macro_rules! write {
56 ($dst:expr, $($tt:tt)*) => {
57 ::core::write!($dst, "{}", $crate::fmt(|_f| {
58 $crate::__fmt!{_f $($tt)*}
59 Ok(())
60 }))
61 };
62}
63
64#[macro_export]
66macro_rules! writeln {
67 ($dst:expr, $($tt:tt)*) => {
68 ::core::write!($dst, "{}", $crate::fmt(|_f| {
69 $crate::__fmt!{_f $($tt)* "\n"}
70 Ok(())
71 }))
72 };
73}
74
75#[cfg(feature = "std")]
77#[macro_export]
78macro_rules! format {
79 ($($tt:tt)*) => {
80 ::std::format!("{}", $crate::fmt(|_f| {
81 $crate::__fmt!{_f $($tt)*}
82 Ok(())
83 }))
84 };
85}
86
87#[macro_export]
89macro_rules! format_args {
90 ($($tt:tt)*) => {
91 ::core::format_args!("{}", $crate::fmt(|_f| {
92 $crate::__fmt!{_f $($tt)*}
93 Ok(())
94 }))
95 };
96}
97
98#[macro_export]
100macro_rules! panic {
101 ($($tt:tt)*) => {
102 ::core::panic!("{}", $crate::fmt(|_f| {
103 $crate::__fmt!{_f $($tt)*}
104 Ok(())
105 }))
106 };
107}
108
109#[test]
110fn test_prelude() {
111 use std::fmt::Write;
112 crate::print!("print");
113 crate::println!("println");
114 crate::eprint!("eprint");
115 crate::eprintln!("eprintln");
116 let mut s = crate::format!("format");
117 let _ = crate::write!(s, "write");
118 let _ = crate::writeln!(s, "writeln");
119 assert_eq!(s, "formatwritewriteln\n");
120 }