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

Method get_value_from_string

crates/vm/src/bytes_inner.rs:54–62  ·  view source on GitHub ↗
(
        s: PyStrRef,
        encoding: PyUtf8StrRef,
        errors: OptionalArg<PyUtf8StrRef>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

52
53impl ByteInnerNewOptions {
54 fn get_value_from_string(
55 s: PyStrRef,
56 encoding: PyUtf8StrRef,
57 errors: OptionalArg<PyUtf8StrRef>,
58 vm: &VirtualMachine,
59 ) -> PyResult<PyBytesInner> {
60 let bytes = pystr::encode_string(s, Some(encoding), errors.into_option(), vm)?;
61 Ok(bytes.as_bytes().to_vec().into())
62 }
63
64 fn get_value_from_source(source: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyBytesInner> {
65 bytes_from_object(vm, &source).map(|x| x.into())

Callers

nothing calls this directly

Calls 5

into_optionMethod · 0.80
to_vecMethod · 0.80
encode_stringFunction · 0.50
SomeClass · 0.50
as_bytesMethod · 0.45

Tested by

no test coverage detected