pub enum Polymorphism {
Traits,
Interfaces,
Typeclasses,
}Expand description
How a language attaches behaviour to types.
All three resolve members through the same engine (impl blocks and
classes’ declared interfaces are both implementations). The difference is
what an interface name means where a type is expected: with
Interfaces, the interface type (a dyn value, as in Java or Kraken);
with Traits and Typeclasses, an error (write dyn Trait or
impl Trait).
§Examples
use typeck_lang::Polymorphism;
assert_ne!(Polymorphism::Traits, Polymorphism::Typeclasses);Variants§
Traits
Nominal implementations, coherent, separate from the type (Rust).
Interfaces
Declared at the class, checked structurally against the interface (Java, Go, Kraken).
Typeclasses
Dictionary-passing typeclasses (Haskell).
Trait Implementations§
Source§impl Clone for Polymorphism
impl Clone for Polymorphism
impl Copy for Polymorphism
Source§impl Debug for Polymorphism
impl Debug for Polymorphism
impl Eq for Polymorphism
Source§impl Hash for Polymorphism
impl Hash for Polymorphism
Source§impl PartialEq for Polymorphism
impl PartialEq for Polymorphism
impl StructuralPartialEq for Polymorphism
Auto Trait Implementations§
impl Freeze for Polymorphism
impl RefUnwindSafe for Polymorphism
impl Send for Polymorphism
impl Sync for Polymorphism
impl Unpin for Polymorphism
impl UnsafeUnpin for Polymorphism
impl UnwindSafe for Polymorphism
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