Returns the underlying string slice.
(&self)
| 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] { |
no test coverage detected