(
&self,
key: &K,
vm: &VirtualMachine,
)
| 657 | } |
| 658 | |
| 659 | pub fn get_item_opt<K: DictKey + ?Sized>( |
| 660 | &self, |
| 661 | key: &K, |
| 662 | vm: &VirtualMachine, |
| 663 | ) -> PyResult<Option<PyObjectRef>> { |
| 664 | if self.exact_dict(vm) { |
| 665 | self.entries.get(vm, key) |
| 666 | // FIXME: check __missing__? |
| 667 | } else { |
| 668 | match self.as_object().get_item(key, vm) { |
| 669 | Ok(value) => Ok(Some(value)), |
| 670 | Err(e) if e.fast_isinstance(vm.ctx.exceptions.key_error) => { |
| 671 | self.missing_opt(key, vm) |
| 672 | } |
| 673 | Err(e) => Err(e), |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | /// Return a cached-entry hint for exact dict fast paths. |
| 679 | pub(crate) fn hint_for_key<K: DictKey + ?Sized>( |
no test coverage detected