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

Method from_vectorcall_owned

crates/vm/src/function/argument.rs:173–199  ·  view source on GitHub ↗

Convert owned vectorcall args to FuncArgs (moves values, no clone).

(
        mut args: Vec<PyObjectRef>,
        nargs: usize,
        kwnames: Option<&[PyObjectRef]>,
    )

Source from the content-addressed store, hash-verified

171
172 /// Convert owned vectorcall args to FuncArgs (moves values, no clone).
173 pub fn from_vectorcall_owned(
174 mut args: Vec<PyObjectRef>,
175 nargs: usize,
176 kwnames: Option<&[PyObjectRef]>,
177 ) -> Self {
178 debug_assert!(nargs <= args.len());
179 debug_assert!(kwnames.is_none_or(|kw| nargs + kw.len() <= args.len()));
180 let kwargs = if let Some(names) = kwnames {
181 let kw_count = names.len();
182 names
183 .iter()
184 .zip(args.drain(nargs..nargs + kw_count))
185 .map(|(name, val)| {
186 let key = name
187 .downcast_ref::<crate::builtins::PyUtf8Str>()
188 .expect("kwnames must be strings")
189 .as_str()
190 .to_owned();
191 (key, val)
192 })
193 .collect()
194 } else {
195 IndexMap::new()
196 };
197 args.truncate(nargs);
198 Self { args, kwargs }
199 }
200
201 pub fn is_empty(&self) -> bool {
202 self.args.is_empty() && self.kwargs.is_empty()

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
collectMethod · 0.80
lenMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
drainMethod · 0.45
to_ownedMethod · 0.45
as_strMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected