Skip to content

Commit e4c4c03

Browse files
committed
* remove nightly reference to negative implementation
* add reference to nomicon
1 parent a58b5fd commit e4c4c03

File tree

2 files changed

+17
-40
lines changed

2 files changed

+17
-40
lines changed

src/en/standard.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ references:
44
title: Specialization
55
url: https://github.com/rust-lang/rfcs/blob/master/text/1210-impl-specialization.md
66
id: RFC-1210
7+
- type: web
8+
title: The Rustonomicon
9+
url: https://doc.rust-lang.org/stable/nomicon/
10+
id: nomicon
711
---
812

913
# Standard library
@@ -26,7 +30,7 @@ implementation may lead to **undefined behavior**.
2630
Fortunately, in most cases, one does not need to implement it. In Rust,
2731
almost all primitive types are `Send` and `Sync`, and for most compound types
2832
the implementation is automatically provided by the Rust compiler.
29-
Notable exceptions are:
33+
As mentioned in [@nomicon], notable exceptions are:
3034

3135
- Raw pointers are neither `Send` nor `Sync` because they offer no safety
3236
guards.
@@ -37,25 +41,10 @@ Notable exceptions are:
3741

3842
Automatic implementation of `Send` (resp. `Sync`) occurs for a compound type
3943
(structure or enumeration) when all fields have `Send` types (resp. `Sync`
40-
types). Using an unstable feature (as of Rust 1.37.0), one can block the
41-
automatic implementation of those traits with a manual
42-
_negative implementation_:
43-
44-
```rust,ignore,noplaypen
45-
#![feature(option_builtin_traits)]
46-
47-
struct SpecialType(u8);
48-
impl !Send for SpecialType {}
49-
impl !Sync for SpecialType {}
50-
```
51-
52-
The negative implementation of `Send` or `Sync` are also used in the Rust
53-
library for the exceptions, and are automatically implemented when appropriate.
54-
As a result, the generated documentation is always explicit: a type implements
55-
either `Send` or `!Send` (resp. `Sync` or `!Sync`).
44+
types).
5645

57-
As a stable alternative to negative implementation, one can use a `PhantomData`
58-
field:
46+
Preventing from automatically implementing `Send` or `Sync` can be made by using
47+
internal fields of type `PhantomData`.
5948

6049
```rust,noplaypen
6150
# use std::marker::PhantomData;

src/fr/standard.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ references:
44
title: Specialization
55
url: https://github.com/rust-lang/rfcs/blob/master/text/1210-impl-specialization.md
66
id: RFC-1210
7+
- type: web
8+
title: The Rustonomicon
9+
url: https://doc.rust-lang.org/stable/nomicon/
10+
id: nomicon
711
---
812

913
# Bibliothèque standard
@@ -28,8 +32,8 @@ réel : une implémentation incorrecte peut mener à un **comportement indéfini
2832
Heureusement, dans la plupart des cas, il n'est pas nécessaire de fournir une
2933
implémentation. En Rust, la quasi-totalité des types primitifs implémente
3034
`Send` et `Sync`, et dans la majorité des cas, Rust fournit de manière
31-
automatique une implémentation pour les types composés. Quelques exceptions
32-
notables sont :
35+
automatique une implémentation pour les types composés. Comme rappelé dans
36+
[@nomicon], quelques exceptions notables sont :
3337

3438
- les pointeurs `raw`, qui n'implémentent ni `Send`, ni `Sync`, puisqu'ils
3539
n'offrent aucune garantie quant à la sûreté ;
@@ -41,26 +45,10 @@ notables sont :
4145

4246
L'implémentation automatique de `Send` (respectivement `Sync`) a lieu pour les
4347
types composés (structures ou énumérations) lorsque tous les champs contenus
44-
implémentent `Send` (respectivement `Sync`). Une fonctionnalité notable, mais
45-
**instable**, de Rust (depuis 1.37.0) permet d'empêcher cette implémentation
46-
automatique en annotant explicitement le type considéré avec une
47-
_négation d'implementation_ :
48-
49-
```rust,ignore,noplaypen
50-
#![feature(option_builtin_traits)]
48+
implémentent `Send` (respectivement `Sync`).
5149

52-
struct SpecialType(u8);
53-
impl !Send for SpecialType {}
54-
impl !Sync for SpecialType {}
55-
```
56-
L'implémentation négative de `Send` ou `Sync` est également utilisée dans la
57-
bibliothèque Rust pour les exceptions, et est automatiquement implémentée
58-
lorsque cela est approprié. En résultat, la documentation générée est toujours
59-
explicite : un type implémente soit `Send` (respectivement `Sync`), soit
60-
`!Send` (respectivement `!Sync`).
61-
62-
En guise d'alternative *stable* à l'implémentation négative, il est possible
63-
d'utiliser un champ typé par un type fantôme (`PhantomData`) :
50+
Afin d’empêcher *artificiellement* qu'un type n'implémente `Send` ou `Sync`,
51+
il est possible d'utiliser un champ typé par un type fantôme (`PhantomData`) :
6452

6553
```rust,noplaypen
6654
# use std::marker::PhantomData;

0 commit comments

Comments
 (0)