3 unstable releases
0.2.0 | Aug 22, 2024 |
---|---|
0.1.1 | Aug 22, 2024 |
0.1.0 | Aug 22, 2024 |
#548 in Procedural macros
7KB
51 lines
console-log-rs
For when console.log
strikes again...
Example
use console_log_rs::console_log;
#[console_log]
mod test_module {
pub fn test_function() {
console.log("This is a test");
}
pub fn test_function_formatted() {
console.log("This is a test {}", 5);
}
}
#[console_log(msg!)]
mod test_msg {
macro_rules! msg {
($msg:expr) => {
println!("using msg macro");
println!($msg)
};
($($arg:tt)*) => {
println!("using msg macro");
println!($($arg)*);
}
}
pub fn test_function() {
console.log("This is a test");
}
pub fn test_function_formatted() {
console.log("This is a test {}", 5);
}
}
fn main() {
test_module::test_function();
test_module::test_function_formatted();
println!();
test_msg::test_function();
test_msg::test_function_formatted();
}
Output:
This is a test
This is a test 5
using msg macro
This is a test
using msg macro
This is a test 5
Dependencies
~240–690KB
~16K SLoC