rust/src/libstd/kinds.rs

54 lines
1.6 KiB
Rust
Raw Normal View History

2012-12-10 17:44:02 -06:00
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
2012-11-30 03:31:56 -06:00
/*!
The kind traits
2012-11-30 14:39:44 -06:00
Rust types can be classified in various useful ways according to
2012-11-30 03:31:56 -06:00
intrinsic properties of the type. These classifications, often called
'kinds', are represented as traits.
They cannot be implemented by user code, but are instead implemented
by the compiler automatically for the types to which they apply.
The 4 kinds are
* Copy - types that may be copied without allocation. This includes
scalar types and managed pointers, and exludes owned pointers. It
also excludes types that implement `Drop`.
2012-12-11 15:50:04 -06:00
* Owned - owned types and types containing owned types. These types
2012-11-30 03:31:56 -06:00
may be transferred across task boundaries.
* Const - types that are deeply immutable. Const types are used for
freezable data structures.
`Copy` types include both implicitly copyable types that the compiler
will copy automatically and non-implicitly copyable types that require
the `copy` keyword to copy. Types that do not implement `Copy` may
instead implement `Clone`.
*/
#[lang="copy"]
pub trait Copy {
// Empty.
}
2012-12-11 15:50:04 -06:00
#[lang="owned"]
pub trait Owned {
// Empty.
}
2012-11-30 03:31:56 -06:00
#[lang="const"]
pub trait Const {
// Empty.
}