file explorer file info, multi-byte char deleting fix

more docs, reversi game win/lose/tie and restart
This commit is contained in:
stjet
2025-01-25 23:04:20 +00:00
parent 03f1d649e0
commit 8d0a317819
8 changed files with 139 additions and 39 deletions

View File

@@ -3,6 +3,7 @@ use std::path::PathBuf;
pub trait Substring {
fn substring(&self, start: usize, end: usize) -> &str;
fn remove(&self, index: usize, len: usize) -> String;
fn remove_last(&self) -> String;
}
impl Substring for String {
@@ -25,7 +26,11 @@ impl Substring for String {
}
fn remove(&self, index: usize, len: usize) -> String {
self.substring(0, index).to_string() + self.substring(index + len, self.len())
self.substring(0, index).to_string() + self.substring(index + len, self.chars().count())
}
fn remove_last(&self) -> String {
self.substring(0, self.chars().count() - 1).to_string()
}
}