MCPcopy Index your code
hub / github.com/RustPython/RustPython / new_substr

Method new_substr

crates/vm/src/builtins/str.rs:455–467  ·  view source on GitHub ↗
(&self, s: Wtf8Buf)

Source from the content-addressed store, hash-verified

453 }
454
455 fn new_substr(&self, s: Wtf8Buf) -> Self {
456 let kind = if self.kind().is_ascii() || s.is_ascii() {
457 StrKind::Ascii
458 } else if self.kind().is_utf8() || s.is_utf8() {
459 StrKind::Utf8
460 } else {
461 StrKind::Wtf8
462 };
463 unsafe {
464 // SAFETY: kind is properly decided for substring
465 Self::new_str_unchecked(s.into(), kind)
466 }
467 }
468
469 #[inline]
470 pub const fn as_wtf8(&self) -> &Wtf8 {

Callers 3

splitlinesMethod · 0.80
partitionMethod · 0.80
rpartitionMethod · 0.80

Calls 3

is_asciiMethod · 0.45
kindMethod · 0.45
is_utf8Method · 0.45

Tested by

no test coverage detected