This commit is contained in:
2026-04-28 14:05:55 +07:00
parent 56c4cdb95a
commit f64b473e2d
3 changed files with 93 additions and 36 deletions

View File

@@ -2,6 +2,24 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "autocfg"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]] [[package]]
name = "rust" name = "rust"
version = "0.1.0" version = "0.1.0"
dependencies = [
"substring",
]
[[package]]
name = "substring"
version = "1.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86"
dependencies = [
"autocfg",
]

View File

@@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
substring = "1.4.5"

View File

@@ -11,41 +11,7 @@
/* --------------------------------------------- 100 -------------------------------------------- */ /* --------------------------------------------- 100 -------------------------------------------- */
// use substring::Substring;
@@ -56,5 +22,77 @@
fn main() { fn main() {
println!("Hello, world!");
let text = "Hello, world! How are you?";
// let mut count = 1;
// let textlength = text.len();
let mut wordlist: Vec<String> = vec![];
let mut word = String::new();
// Loop through characters directly
for c in text.chars() {
if c != ' ' { // Use char, not string
word.push(c); // push works with char
} else {
println!("word {word}");
wordlist.push(word.clone());
word.clear();
}
}
println!("{:?}", wordlist); // Works
// // loop over each character in text
// while count > textlength {
// let start_index = count - 1;
// let char = text.substring(start_index, count);
// if char != " " {
// word.push_str(char);
// }
} }