formatting fixes
This commit is contained in:
parent
d07825258e
commit
d5ef9f9036
@ -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) );
|
||||
}
|
||||
```
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user