File tree Expand file tree Collapse file tree 1 file changed +36
-5
lines changed Expand file tree Collapse file tree 1 file changed +36
-5
lines changed Original file line number Diff line number Diff line change 1- //! The kind traits
1+ /*!
2+ The kind traits
23
3- #[ lang="const" ]
4- pub trait Const {
5- // Empty.
6- }
4+ Rust types can be classified in vairous useful ways according to
5+ intrinsic properties of the type. These classifications, often called
6+ 'kinds', are represented as traits.
7+
8+ They cannot be implemented by user code, but are instead implemented
9+ by the compiler automatically for the types to which they apply.
10+
11+ The 4 kinds are
12+
13+ * Copy - types that may be copied without allocation. This includes
14+ scalar types and managed pointers, and exludes owned pointers. It
15+ also excludes types that implement `Drop`.
16+
17+ * Send - owned types and types containing owned types. These types
18+ may be transferred across task boundaries.
19+
20+ * Const - types that are deeply immutable. Const types are used for
21+ freezable data structures.
22+
23+ * Owned - types that do not contain borrowed pointers. Note that this
24+ meaning of 'owned' conflicts with 'owned pointers'. The two notions
25+ of ownership are different.
26+
27+ `Copy` types include both implicitly copyable types that the compiler
28+ will copy automatically and non-implicitly copyable types that require
29+ the `copy` keyword to copy. Types that do not implement `Copy` may
30+ instead implement `Clone`.
31+
32+ */
733
834#[ lang="copy" ]
935pub trait Copy {
@@ -15,6 +41,11 @@ pub trait Send {
1541 // Empty.
1642}
1743
44+ #[ lang="const" ]
45+ pub trait Const {
46+ // Empty.
47+ }
48+
1849#[ lang="owned" ]
1950pub trait Owned {
2051 // Empty.
You can’t perform that action at this time.
0 commit comments