mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
Add clarifying note to KwArgs docs
This commit is contained in:
1 parent
d3b9714754
commit
e83686cf3c
1 file changed
+8
-1
+8
-1
@@ -192,14 +192,21 @@ pub trait FromArgs: Sized {
|
||||
/// Extracts this item from the next argument(s).
|
||||
fn from_args(vm: &mut VirtualMachine, args: &mut PyFuncArgs) -> Result<Self, ArgumentError>;
|
||||
}
|
||||
|
||||
/// A map of keyword arguments to their values.
|
||||
///
|
||||
/// A built-in function with a `KwArgs` parameter is analagous to a Python
|
||||
/// function with `*kwargs`. All remaining keyword arguments are extracted
|
||||
/// function with `**kwargs`. All remaining keyword arguments are extracted
|
||||
/// (and hence the function will permit an arbitrary number of them).
|
||||
///
|
||||
/// `KwArgs` optionally accepts a generic type parameter to allow type checks
|
||||
/// or conversions of each argument.
|
||||
///
|
||||
/// Note:
|
||||
///
|
||||
/// KwArgs is only for functions that accept arbitrary keyword arguments. For
|
||||
/// functions that accept only *specific* named arguments, a rust struct with
|
||||
/// an appropriate FromArgs implementation must be created.
|
||||
pub struct KwArgs<T = PyObjectRef>(HashMap<String, T>);
|
||||
|
||||
impl<T> FromArgs for KwArgs<T>
|
||||
|
||||
Reference in new issue
Block a user