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

Method as_str

crates/vm/src/builtins/str.rs:2133–2140  ·  view source on GitHub ↗

Returns the underlying string slice.

(&self)

Source from the content-addressed store, hash-verified

2131
2132 /// Returns the underlying string slice.
2133 pub fn as_str(&self) -> &str {
2134 debug_assert!(
2135 self.0.is_utf8(),
2136 "PyUtf8Str invariant violated: inner string is not valid UTF-8"
2137 );
2138 // Safety: This is safe because the type invariant guarantees UTF-8 validity.
2139 unsafe { self.0.to_str().unwrap_unchecked() }
2140 }
2141
2142 #[inline]
2143 pub fn as_bytes(&self) -> &[u8] {

Callers 15

__replace__Method · 0.45
update_slotMethod · 0.45
update_subclassesMethod · 0.45
update_one_slotMethod · 0.45
from_vectorcallMethod · 0.45
from_vectorcall_ownedMethod · 0.45
dirMethod · 0.45
method_output_as_listMethod · 0.45
callMethod · 0.45
getpwnamFunction · 0.45
breakpointhookFunction · 0.45
is_builtinFunction · 0.45

Calls 2

to_strMethod · 0.80
as_pystrMethod · 0.80

Tested by

no test coverage detected