Generics and Polymorphism
- What is an algebraic data type?
An algebraic data type is a kind of compositetype formed by combining other types.
- What is polymorphism?
Polymorphism is the quality of having many forms.
- What is parametric polymorphism?
Parametric polymorphism is the quality of having many forms according to a parameter.
- What is a ground type?
A ground type is a type that has no parameters, modifiers, or substitutions. For example, i32
or String
.
- What is Universal Function Call syntax?
Universal Function Call syntax is used to disambiguate functions or methods. It looks like Foo::f(&b)
instead of b.f()
.
- What are the possible type signatures of a trait object?
A trait object is any signature for a trait that will give it a known size at compile time. Common examples of this are &Trait
or Box<Trait>
.
- What are two ways to obscure type information?
Trait objects and traits in general hide information. Associated types also reduce the amount of information necessary to interact with code.
- How is a subtrait declared?
trait SuperTrait: SubTrait1 + SubTrait2 {}