MCPcopy Create free account
hub / github.com/SSheldon/rust-objc / from_str

Function from_str

src/encode.rs:91–101  ·  view source on GitHub ↗
(code: &str)

Source from the content-addressed store, hash-verified

89}
90
91pub fn from_str(code: &str) -> Encoding {
92 if code.len() > CODE_INLINE_CAP {
93 Encoding { code: Code::Owned(code.to_owned()) }
94 } else {
95 let mut bytes = [0; CODE_INLINE_CAP];
96 for (dst, byte) in bytes.iter_mut().zip(code.bytes()) {
97 *dst = byte;
98 }
99 Encoding { code: Code::Inline(code.len() as u8, bytes) }
100 }
101}
102
103pub unsafe fn from_malloc_str(ptr: *mut c_char) -> Encoding {
104 let s = CStr::from_ptr(ptr);

Callers 6

from_strMethod · 0.85
cloneMethod · 0.85
test_inline_encodingFunction · 0.85
test_owned_encodingFunction · 0.85
type_encodingMethod · 0.85
encodeMethod · 0.85

Calls

no outgoing calls

Tested by 3

test_inline_encodingFunction · 0.68
test_owned_encodingFunction · 0.68
encodeMethod · 0.68