Skip to content

Commit

Permalink
Implement more basic traits for the marker types.
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Nov 16, 2014
1 parent 7e43f41 commit f975243
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/libcore/kinds.rs
Expand Up @@ -132,7 +132,7 @@ pub mod marker {
/// (for example, `S<&'static int>` is a subtype of `S<&'a int>`
/// for some lifetime `'a`, but not the other way around).
#[lang="covariant_type"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct CovariantType<T>;

/// A marker type whose type parameter `T` is considered to be
Expand Down Expand Up @@ -175,7 +175,7 @@ pub mod marker {
/// function requires arguments of type `T`, it must also accept
/// arguments of type `U`, hence such a conversion is safe.
#[lang="contravariant_type"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct ContravariantType<T>;

/// A marker type whose type parameter `T` is considered to be
Expand All @@ -200,7 +200,7 @@ pub mod marker {
/// never written, but in fact `Cell` uses unsafe code to achieve
/// interior mutability.
#[lang="invariant_type"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct InvariantType<T>;

/// As `CovariantType`, but for lifetime parameters. Using
Expand All @@ -220,7 +220,7 @@ pub mod marker {
/// For more information about variance, refer to this Wikipedia
/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
#[lang="covariant_lifetime"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct CovariantLifetime<'a>;

/// As `ContravariantType`, but for lifetime parameters. Using
Expand All @@ -236,7 +236,7 @@ pub mod marker {
/// For more information about variance, refer to this Wikipedia
/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
#[lang="contravariant_lifetime"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct ContravariantLifetime<'a>;

/// As `InvariantType`, but for lifetime parameters. Using
Expand All @@ -247,34 +247,34 @@ pub mod marker {
/// and this pointer is itself stored in an inherently mutable
/// location (such as a `Cell`).
#[lang="invariant_lifetime"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct InvariantLifetime<'a>;

/// A type which is considered "not sendable", meaning that it cannot
/// be safely sent between tasks, even if it is owned. This is
/// typically embedded in other types, such as `Gc`, to ensure that
/// their instances remain thread-local.
#[lang="no_send_bound"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct NoSend;

/// A type which is considered "not POD", meaning that it is not
/// implicitly copyable. This is typically embedded in other types to
/// ensure that they are never copied, even if they lack a destructor.
#[lang="no_copy_bound"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct NoCopy;

/// A type which is considered "not sync", meaning that
/// its contents are not threadsafe, hence they cannot be
/// shared between tasks.
#[lang="no_sync_bound"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct NoSync;

/// A type which is considered managed by the GC. This is typically
/// embedded in other types.
#[lang="managed_bound"]
#[deriving(PartialEq,Clone)]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Managed;
}

5 comments on commit f975243

@bors
Copy link
Contributor

@bors bors commented on f975243 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at huonw@f975243

@bors
Copy link
Contributor

@bors bors commented on f975243 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging huonw/rust/more-marker-impls = f975243 into auto

@bors
Copy link
Contributor

@bors bors commented on f975243 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huonw/rust/more-marker-impls = f975243 merged ok, testing candidate = 88c743d

@bors
Copy link
Contributor

@bors bors commented on f975243 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on f975243 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 88c743d

Please sign in to comment.