Skip to content

Commit 38ba2c4

Browse files
committed
core: Add docs about kind traits
1 parent b52a4b4 commit 38ba2c4

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

src/libcore/kinds.rs

+36-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
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"]
935
pub 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"]
1950
pub trait Owned {
2051
// Empty.

0 commit comments

Comments
 (0)