“Rust split” Kode Jawaban

cara membagi string dengan spasi karat

let mut iter = "A few words".split_whitespace();

assert_eq!(Some("A"), iter.next());
assert_eq!(Some("few"), iter.next());
assert_eq!(Some("words"), iter.next());

assert_eq!(None, iter.next());
Flyhouse_Squarewheel

split string karat

let mut split = "some string 123 ffd".split("123");

for s in split {
    println!("{}", s)
}
let vec = split.collect::<Vec<&str>>();
// OR
let vec: Vec<&str> = split.collect();
Mortis_666

Rust split

#![feature(str_split_as_str)]
let mut split = "Mary had a little lamb".split(' ');
assert_eq!(split.as_str(), "Mary had a little lamb");
split.next();
assert_eq!(split.as_str(), "had a little lamb");
split.by_ref().for_each(drop);
assert_eq!(split.as_str(), "");
Energetic Earthworm

Jawaban yang mirip dengan “Rust split”

Pertanyaan yang mirip dengan “Rust split”

Lebih banyak jawaban terkait untuk “Rust split” di Rust

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya