| Crates.io | console-log-rs |
| lib.rs | console-log-rs |
| version | 0.2.0 |
| created_at | 2024-08-22 02:41:31.907941+00 |
| updated_at | 2024-08-22 06:29:27.550109+00 |
| description | replaces console.log in a rust module with println! |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1347214 |
| size | 17,669 |
console-log-rsFor when console.log strikes again...
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