Skip to content

Documentation example for InvariantType is strange #20147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cgaebel opened this issue Dec 23, 2014 · 2 comments · Fixed by #21995
Closed

Documentation example for InvariantType is strange #20147

cgaebel opened this issue Dec 23, 2014 · 2 comments · Fixed by #21995
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@cgaebel
Copy link
Contributor

cgaebel commented Dec 23, 2014

http://doc.rust-lang.org/std/kinds/marker/struct.InvariantType.html

It starts talking about cell for some reason. I think this was copy + pasted from InvariantLifetime and never updated.

@cgaebel
Copy link
Contributor Author

cgaebel commented Dec 23, 2014

cc @steveklabnik

@kmcallister kmcallister added A-docs E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Jan 16, 2015
@huonw
Copy link
Member

huonw commented Feb 1, 2015

InvariantLifetime doesn't have this example (atm), and, the example only makes sense with InvariantType since there's no lifetimes involved in the definition of the Cell type. I do think the example could probably have a little more description, but I don't think it's wrong.

For reference, it currently says:

/// The Cell type is an example which uses unsafe code to achieve
/// "interior" mutability:
///
/// ```
/// struct Cell<T> { value: T }
/// ```
///
/// The type system would infer that `value` is only read here and
/// never written, but in fact `Cell` uses unsafe code to achieve
/// interior mutability.

bors added a commit that referenced this issue Feb 7, 2015
Should fix #20147

This is my second PR in the history of ever (I botched my first one #21828). Any tips would be appreciated!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
3 participants