From da4c7807b37826cfe5ff9d4954696eed4cb1d40a Mon Sep 17 00:00:00 2001 From: pointer-to-bios Date: Mon, 5 Feb 2024 21:57:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BE=E5=BC=83=E4=BD=BF=E7=94=A8=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=9A=84format=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kernel/clock/time.rs | 4 +--- src/libk/string/format/mod.rs | 38 ----------------------------------- src/libk/string/mod.rs | 1 - 3 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 src/libk/string/format/mod.rs diff --git a/src/kernel/clock/time.rs b/src/kernel/clock/time.rs index 29f86bd..a2eea96 100644 --- a/src/kernel/clock/time.rs +++ b/src/kernel/clock/time.rs @@ -1,8 +1,6 @@ use core::{cmp::Ordering, ops::Sub, time::Duration}; -use alloc::string::ToString; - -use crate::format; +use alloc::{format, string::ToString}; extern "C" { fn system_time_get() -> usize; diff --git a/src/libk/string/format/mod.rs b/src/libk/string/format/mod.rs deleted file mode 100644 index 8d63056..0000000 --- a/src/libk/string/format/mod.rs +++ /dev/null @@ -1,38 +0,0 @@ -use alloc::string::{String, ToString}; - -#[macro_export] -macro_rules! format { - ( $s : expr, $( $e : expr ),* ) => {{ - use crate::libk::string::format::Format; - let mut res = $s.to_string(); - $( - res.format($e); - )* - res - }}; - () => {}; -} - -pub trait Format { - fn format(&mut self, f: T); -} - -impl Format for String { - fn format(&mut self, f: T) { - let mut res = String::new(); - let mut formatting = false; - for c in self.chars().into_iter() { - if c == '{' { - formatting = true; - res += &f.to_string(); - } else if c == '}' { - formatting = false; - } - if !formatting { - res.push(c); - } - } - self.clear(); - self.push_str(&res); - } -} diff --git a/src/libk/string/mod.rs b/src/libk/string/mod.rs index db7b59d..e69de29 100644 --- a/src/libk/string/mod.rs +++ b/src/libk/string/mod.rs @@ -1 +0,0 @@ -pub mod format;