formatting fixes

This commit is contained in:
tinaun 2017-10-10 05:03:47 -04:00
parent d07825258e
commit d5ef9f9036
3 changed files with 20 additions and 22 deletions

View File

@ -6,44 +6,42 @@ The tracking issue for this feature is [#13231]
----
The `optin_builtin_traits` feature gate allows you to define _auto traits_.
The `optin_builtin_traits` feature gate allows you to define auto traits.
Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits
that are automatically implemented for every type, unless the type, or a type it contains,
has explictly opted out via a _negative impl_.
has explictly opted out via a negative impl.
[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
[`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
```rust, ignore
```rust,ignore
impl !Type for Trait
```
Example:
```rust
#![feature(optin_builtin_traits)]
#![feature(optin_builtin_traits)]
trait Valid {}
trait Valid {}
impl Valid for .. {}
impl Valid for .. {}
struct True;
struct False;
struct True;
struct False;
impl !Valid for False {}
impl !Valid for False {}
struct MaybeValid<T>(T);
struct MaybeValid<T>(T);
fn must_be_valid<T: Valid>(_t: T) {
fn must_be_valid<T: Valid>(_t: T) { }
}
fn main() {
//works
must_be_valid( MaybeValid(True) );
fn main() {
// works
must_be_valid( MaybeValid(True) );
// compiler error - trait bound not satisfied
// must_be_valid( MaybeValid(False) );
}
// compiler error - trait bound not satisfied
// must_be_valid( MaybeValid(False) );
}
```

View File

@ -2,7 +2,7 @@
The tracking issue for this feature is [#29625]
See Also: [`fn_traits`](library-features/fn-traits.md)
See Also: [`fn_traits`](library-features/fn-traits.html)
[#29625]: https://github.com/rust-lang/rust/issues/29625
@ -17,7 +17,7 @@ exactly one (non self) argument, a tuple representing the argument list.
```rust
#![feature(unboxed_closures)]
extern "rust-call" fn add_args(args: (u32, u32)) {
extern "rust-call" fn add_args(args: (u32, u32)) -> u32 {
args.0 + args.1
}

View File

@ -2,7 +2,7 @@
The tracking issue for this feature is [#29625]
See Also: [`unboxed_closures`](language-features/unboxed_closures.md)
See Also: [`unboxed_closures`](language-features/unboxed-closures.html)
[#29625]: https://github.com/rust-lang/rust/issues/29625