markertrait
Marker trait is a term used to describe a trait that provides no methods or associated items and exists solely to convey information about a type to the compiler. Marker traits are used in generic programming to express constraints without requiring any behavior from the type. By using a marker trait in a trait bound, code can be conditionally compiled or optimized based on properties of the type rather than its functionality.
In Rust, common examples include Copy, Send, Sync, and Sized. Copy indicates that values can be duplicated
Marker traits are especially useful for enforcing safety and correctness at compile time. They enable generic
Beyond Rust, the concept resembles marker interfaces in other languages, such as Java’s Serializable or Cloneable,