MCPcopy Create free account
hub / github.com/SharpCoder/teensycore / split

Method split

src/system/str.rs:422–443  ·  view source on GitHub ↗

Split the string into a vector of other strings delimited by the attribute provided. ``` use teensycore::*; use teensycore::system::str::*; let string = str!(b"hello\nworld"); let strings = string.split(b'\n'); ```

(&self, target: u8)

Source from the content-addressed store, hash-verified

420 /// let strings = string.split(b'\n');
421 /// ```
422 fn split(&self, target: u8) -> Vector<Str> {
423 let mut result = Vector::new();
424 let mut temp = Str::new();
425
426 for char in self.into_iter() {
427 if char == target {
428 result.push(Str::from_str(&temp));
429 temp.clear();
430 } else {
431 temp.append(&[char]);
432 }
433 }
434
435 if temp.len() > 0 {
436 result.push(Str::from_str(&temp));
437 }
438
439 temp.clear();
440 temp.drop();
441
442 return result;
443 }
444
445 /// Searches Self for a matching content string. Returns
446 /// true if a match is found.

Callers 1

test_splitFunction · 0.45

Calls 6

appendMethod · 0.80
lenMethod · 0.80
dropMethod · 0.80
into_iterMethod · 0.45
pushMethod · 0.45
clearMethod · 0.45

Tested by 1

test_splitFunction · 0.36