diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-08 11:58:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-08 11:58:50 +0800 |
| commit | f694a59dccef877a026c043cee236f57a93033a6 (patch) | |
| tree | 6e67db7939474606aaae9bb01b765b8a4c4784da /src/utils.rs | |
| parent | b7cb6f89f137e20f1d6dbb1f66e40f319c978a45 (diff) | |
| download | aichat-f694a59dccef877a026c043cee236f57a93033a6.tar.gz | |
refactor: replace dump with print_now! (#35)
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/utils.rs b/src/utils.rs index 5a18948..76f2b8f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,8 +1,15 @@ use chrono::prelude::*; use std::io::{stdout, Write}; -pub fn dump<T: ToString>(text: T, newlines: usize) { - print!("{}{}", text.to_string(), "\n".repeat(newlines)); +#[macro_export] +macro_rules! print_now { + ($($arg:tt)*) => { + $crate::utils::print_now(&format!($($arg)*)) + }; +} + +pub fn print_now<T: ToString>(text: T) { + print!("{}", text.to_string()); let _ = stdout().flush(); } |
