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

Method new_method_def

crates/vm/src/vm/context.rs:646–664  ·  view source on GitHub ↗
(
        &self,
        name: &'static str,
        f: F,
        flags: PyMethodFlags,
        doc: Option<&'static str>,
    )

Source from the content-addressed store, hash-verified

644 }
645
646 pub fn new_method_def<F, FKind>(
647 &self,
648 name: &'static str,
649 f: F,
650 flags: PyMethodFlags,
651 doc: Option<&'static str>,
652 ) -> PyRef<HeapMethodDef>
653 where
654 F: IntoPyNativeFn<FKind>,
655 {
656 let def = PyMethodDef {
657 name,
658 func: Box::leak(Box::new(f.into_func())),
659 flags,
660 doc,
661 };
662 let payload = HeapMethodDef::new(def);
663 PyRef::new_ref(payload, self.types.method_def.to_owned(), None)
664 }
665
666 #[inline]
667 pub fn new_member(

Callers 2

new_functionMethod · 0.80
new_methodMethod · 0.80

Calls 4

leakFunction · 0.85
newFunction · 0.85
into_funcMethod · 0.80
to_ownedMethod · 0.45

Tested by

no test coverage detected