Skip to content

Commit

Permalink
Merge pull request #255 from mkroening/println-update
Browse files Browse the repository at this point in the history
refactor: Update print macros from kernel
  • Loading branch information
mkroening authored Aug 10, 2023
2 parents c03ecd0 + 8749279 commit 114175e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
/// Print formatted text to our console.
/// Prints to the standard output.
///
/// From http://blog.phil-opp.com/rust-os/printing-to-screen.html, but tweaked
/// for HermitCore.
/// Adapted from [`std::print`].
///
/// [`std::print`]: https://doc.rust-lang.org/stable/std/macro.print.html
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {{
$crate::_print(::core::format_args!($($arg)*));
}};
}

/// Print formatted text to our console, followed by a newline.
/// Prints to the standard output, with a newline.
///
/// Adapted from [`std::println`].
///
/// [`std::println`]: https://doc.rust-lang.org/stable/std/macro.println.html
#[macro_export]
macro_rules! println {
() => {
$crate::print!("\n")
};
($($arg:tt)*) => {{
print!("{}\n", ::core::format_args!($($arg)*))
$crate::_print(::core::format_args!("{}\n", format_args!($($arg)*)));
}};
}

Expand Down

0 comments on commit 114175e

Please sign in to comment.