aboutsummaryrefslogtreecommitdiff
path: root/src/redefine.rs
blob: 10fb631c5d6953d9a349795f65d56838dfe2d103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// redefine.rs

// Copyright (C) 2019 The Nitrocli Developers
// SPDX-License-Identifier: GPL-3.0-or-later

// A replacement of the standard println!() macro that requires an
// execution context as the first argument and prints to its stdout.
macro_rules! println {
  ($ctx:expr) => {
    writeln!($ctx.stdout, "")
  };
  ($ctx:expr, $($arg:tt)*) => {
    writeln!($ctx.stdout, $($arg)*)
  };
}

macro_rules! print {
  ($ctx:expr, $($arg:tt)*) => {
    write!($ctx.stdout, $($arg)*)
  };
}

macro_rules! eprintln {
  ($ctx:expr) => {
    writeln!($ctx.stderr, "")
  };
  ($ctx:expr, $($arg:tt)*) => {
    writeln!($ctx.stderr, $($arg)*)
  };
}