//! Module implementing the `print!`/`println!` macro.

use core::fmt;

use crate::console;

/// The backend for printing to the console.
pub fn _print(args: fmt::Arguments) {
    console().write_fmt(args).unwrap();
}

/// The printing macro.
#[macro_export]
macro_rules! print {
    ($($arg:tt)*) => ($crate::print::_print(format_args!($($arg)*)));
}

/// The line printing macro.
#[macro_export]
macro_rules! println {
    () => ($crate::print!("\n"));
    ($($arg:tt)*) => ({
        $crate::print::_print(format_args_nl!($($arg)*));
    })
}
