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

Method to_owned

crates/compiler-core/src/bytecode.rs:1018–1055  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1016 }
1017
1018 pub fn to_owned(self) -> ConstantData {
1019 use ConstantData::*;
1020
1021 match self {
1022 BorrowedConstant::Integer { value } => Integer {
1023 value: value.clone(),
1024 },
1025 BorrowedConstant::Float { value } => Float { value },
1026 BorrowedConstant::Complex { value } => Complex { value },
1027 BorrowedConstant::Boolean { value } => Boolean { value },
1028 BorrowedConstant::Str { value } => Str {
1029 value: value.to_owned(),
1030 },
1031 BorrowedConstant::Bytes { value } => Bytes {
1032 value: value.to_owned(),
1033 },
1034 BorrowedConstant::Code { code } => Code {
1035 code: Box::new(code.map_clone_bag(&BasicBag)),
1036 },
1037 BorrowedConstant::Tuple { elements } => Tuple {
1038 elements: elements
1039 .iter()
1040 .map(|c| c.borrow_constant().to_owned())
1041 .collect(),
1042 },
1043 BorrowedConstant::Slice { elements } => Slice {
1044 elements: Box::new(elements.each_ref().map(|c| c.borrow_constant().to_owned())),
1045 },
1046 BorrowedConstant::Frozenset { elements } => Frozenset {
1047 elements: elements
1048 .iter()
1049 .map(|c| c.borrow_constant().to_owned())
1050 .collect(),
1051 },
1052 BorrowedConstant::None => None,
1053 BorrowedConstant::Ellipsis => Ellipsis,
1054 }
1055 }
1056}
1057
1058/*

Callers 15

from_ruff_parse_errorMethod · 0.45
_compile_symtableFunction · 0.45
format_floatMethod · 0.45
format_complex_floatMethod · 0.45
test_parse_keyFunction · 0.45
newMethod · 0.45
found_in_outer_scopeMethod · 0.45
enter_scopeMethod · 0.45
add_classdict_freevarMethod · 0.45

Calls 7

newFunction · 0.85
map_clone_bagMethod · 0.80
collectMethod · 0.80
cloneMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
borrow_constantMethod · 0.45

Tested by 1

test_parse_keyFunction · 0.36