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

Method slot_new

crates/stdlib/src/contextvars.rs:496–512  ·  view source on GitHub ↗
(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

494 type Args = ContextVarOptions;
495
496 fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
497 let args: Self::Args = args.bind(vm)?;
498 let var = Self {
499 name: args.name.to_string(),
500 default: args.default.into_option(),
501 cached_id: 0.into(),
502 cached: AtomicCell::new(None),
503 hash: UnsafeCell::new(0),
504 };
505 let py_var = var.into_ref_with_type(vm, cls)?;
506
507 unsafe {
508 // SAFETY: py_var is not exposed to python memory model yet
509 *py_var.hash.get() = Self::generate_hash(&py_var, vm)
510 };
511 Ok(py_var.into())
512 }
513
514 fn py_new(_cls: &Py<PyType>, _args: Self::Args, _vm: &VirtualMachine) -> PyResult<Self> {
515 unimplemented!("use slot_new")

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
to_stringMethod · 0.80
into_optionMethod · 0.80
into_ref_with_typeMethod · 0.80
ErrClass · 0.50
bindMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected