MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / new_impl

Method new_impl

src/objects/string.rs:247–253  ·  view source on GitHub ↗
(py: Python, s: &str)

Source from the content-addressed store, hash-verified

245 pub fn new(py: Python, s: &str) -> PyString {
246 #[cfg(feature = "python27-sys")]
247 fn new_impl(py: Python, s: &str) -> PyString {
248 if cfg!(feature = "py2-no-auto-unicode-promotion") || s.is_ascii() {
249 PyBytes::new(py, s.as_bytes()).into_basestring()
250 } else {
251 PyUnicode::new(py, s).into_basestring()
252 }
253 }
254 #[cfg(feature = "python3-sys")]
255 fn new_impl(py: Python, s: &str) -> PyString {
256 let ptr = s.as_ptr() as *const c_char;

Callers

nothing calls this directly

Calls 5

into_basestringMethod · 0.80
as_ptrMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected