Skip to content

Commit 31db5b5

Browse files
Merge pull request #20409 from A4-Tacks/minicore-write
Add write! and writeln! to minicore
2 parents 44bdfdf + d5afd99 commit 31db5b5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/test-utils/src/minicore.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
//! tuple:
7171
//! unpin: sized
7272
//! unsize: sized
73+
//! write: fmt
7374
//! todo: panic
7475
//! unimplemented: panic
7576
//! column:
@@ -1769,6 +1770,26 @@ mod macros {
17691770
}
17701771
// endregion:panic
17711772

1773+
// region:write
1774+
#[macro_export]
1775+
macro_rules! write {
1776+
($dst:expr, $($arg:tt)*) => {
1777+
$dst.write_fmt($crate::format_args!($($arg)*))
1778+
};
1779+
}
1780+
1781+
#[macro_export]
1782+
#[allow_internal_unstable(format_args_nl)]
1783+
macro_rules! writeln {
1784+
($dst:expr $(,)?) => {
1785+
$crate::write!($dst, "\n")
1786+
};
1787+
($dst:expr, $($arg:tt)*) => {
1788+
$dst.write_fmt($crate::format_args_nl!($($arg)*))
1789+
};
1790+
}
1791+
// endregion:write
1792+
17721793
// region:assert
17731794
#[macro_export]
17741795
#[rustc_builtin_macro]

0 commit comments

Comments
 (0)