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

Method __getitem__

crates/stdlib/src/contextvars.rs:185–195  ·  view source on GitHub ↗
(
            &self,
            var: PyRef<ContextVar>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

183 }
184
185 fn __getitem__(
186 &self,
187 var: PyRef<ContextVar>,
188 vm: &VirtualMachine,
189 ) -> PyResult<PyObjectRef> {
190 let vars = self.borrow_vars();
191 let item = vars
192 .get(&*var)
193 .ok_or_else(|| vm.new_key_error(var.into()))?;
194 Ok(item.to_owned())
195 }
196
197 fn __len__(&self) -> usize {
198 self.borrow_vars().len()

Callers

nothing calls this directly

Calls 5

borrow_varsMethod · 0.80
ok_or_elseMethod · 0.80
new_key_errorMethod · 0.80
getMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected