C - Derivable Traits
Oxide uses the same derive system as Rust. You can automatically implement
common traits with #[derive(...)].
Here are the most commonly derivable traits:
Debug- Enables formatting with{:?}Clone- Allows explicit cloningCopy- Allows bitwise copies for simple typesEq/PartialEq- Equality comparisonsOrd/PartialOrd- Ordering comparisonsHash- Enables hashing, useful forHashMapkeysDefault- Provides a default value
Example
#[derive(Debug, Clone, PartialEq, Eq)]
public struct Point {
public x: Int,
public y: Int,
}
Not all traits are derivable for all types. For example, Copy requires that
all fields are also Copy.