pub struct SingleDispatchData {
pub name: String,
pub default: Value,
pub registry: Mutex<IndexMap<String, Value>>,
}Expand description
Shared state for Value::SingleDispatch — a
functools.singledispatch generic function. The default
implementation handles argument types with no registered override;
registry maps a type name to its implementation, in registration
order. Shared behind an Arc so the .register decorator (which
clones the wrapper value) mutates the same table the caller dispatches
against, matching CPython’s single generic-function object.
Fields§
§name: StringReported name (the decorated function’s __name__).
default: ValueFallback implementation (the originally decorated function).
registry: Mutex<IndexMap<String, Value>>Type-name → implementation, in registration order. Dispatch walks the argument type’s MRO and picks the first match.
Trait Implementations§
Source§impl Debug for SingleDispatchData
impl Debug for SingleDispatchData
Source§impl<'de> Deserialize<'de> for SingleDispatchData
impl<'de> Deserialize<'de> for SingleDispatchData
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for SingleDispatchData
impl !RefUnwindSafe for SingleDispatchData
impl !UnwindSafe for SingleDispatchData
impl Send for SingleDispatchData
impl Sync for SingleDispatchData
impl Unpin for SingleDispatchData
impl UnsafeUnpin for SingleDispatchData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more