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

Method current

crates/stdlib/src/contextvars.rs:129–142  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

127 }
128
129 fn current(vm: &VirtualMachine) -> PyRef<Self> {
130 super::CONTEXTS.with_borrow_mut(|ctxs| {
131 if let Some(ctx) = ctxs.last() {
132 ctx.clone()
133 } else {
134 let ctx = Self::empty(vm);
135 ctx.inner.idx.set(0);
136 ctx.inner.entered.set(true);
137 let ctx = ctx.into_ref(&vm.ctx);
138 ctxs.push(ctx);
139 ctxs[0].clone()
140 }
141 })
142 }
143
144 fn contains(&self, needle: &Py<ContextVar>) -> PyResult<bool> {
145 let vars = self.borrow_vars();

Callers

nothing calls this directly

Calls 5

lastMethod · 0.45
cloneMethod · 0.45
setMethod · 0.45
into_refMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected