| 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 | /* |