Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded Frequently Asked Questions Page #202
Conversation
AndrewBrinker
added some commits
Sep 1, 2015
rust-highfive
assigned
brson
Oct 22, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rust-highfive
Oct 22, 2015
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.
If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.
Please see the contribution instructions for more information.
rust-highfive
commented
Oct 22, 2015
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
\o/ Woah! So much web site. Thanks. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Diggsey
Oct 23, 2015
Some thoughts while reading through it:
- Why does "very small and limited runtime" link to lazy_static?
- "Can I use globals across threads without unsafe" - You can use them as long as they're Sync and don't implement Drop, you just can't mutate them.
- "there is no total ordering for floating point numbers" - Technically, the spec does define several possible total orderings for floating point numbers, at least one of which is implemented by an external crate - maybe link to it?
- "How do I return a borrow to something I created from a function?" - Maybe suggest returning an owning type like String instead, and possibly mention Cow.
- "How can I define a struct that contains a pointer to one of its own fields?" - I think you can actually do this, but it's useless as the struct becomes permanently borrowed (by itself), and so cannot ever be moved.
- "What is the difference between consuming and moving/taking ownership?" - They're actually the same thing. When you call a method which consumes
self, there's no requirement thatselfis dropped, it's simply moved into the method. - "Using Deref coercions! Strings and Vecs will automatically coerce to their respective slices when referenced" - The term "referenced" is very ambiguous here, maybe make it clear that you mean using
&var. - "How do I do O(1) character access in a String?" - You can:
strimplements both Index and IndexMut, and so indexing is available via bothStringand&str. The caveats you mentioned still apply, but rather than getting out nonsense data, indexing will panic if it's not a valid UTF8 boundary. - "The char type is UCS4" - Actually, it's UTF32, which is subtly different because it disallows values outside the range 0-0x10FFFF, or within the range reserved for UTF16 surrogates. This is necessary to ensure that it can only contain valid unicode characters.
- "Modules and Crates" - Maybe mention that
usedeclarations are always relative to the crate root, rather than the current module, which is different from how name resolution works for everything else. This is one of the most confusing things when first using rust's module system. - "What is "monomorphisation" - C++ programmers will know this as template instantiation. In rust however, it's an implementation detail rather than a language feature.
- "How does Rust's ownership system related to move semantics in C++?" - Maybe note that unlike in rust, in C++ destructors are still called after a value has been moved, ie. it's a destructive copy rather than an actual move.
- "Does Rust have C++-style constructors?" - Mention that methods which construct value are typically named "new".
Diggsey
commented
Oct 23, 2015
|
Some thoughts while reading through it:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Oct 23, 2015
Contributor
Wonderful! This is exactly the input I'm looking for:
Why does "very small and limited runtime" link to lazy_static?
Ah, mistake during editing. Fixing now.
"Can I use globals across threads without unsafe" - You can use them as long as they're Sync and don't implement Drop, you just can't mutate them.
Good to know. I've updated my answer accordingly.
"there is no total ordering for floating point numbers" - Technically, the spec does define several possible total orderings for floating point numbers, at least one of which is implemented by an external crate - maybe link to it?
Do you know which crate?
"How do I return a borrow to something I created from a function?" - Maybe suggest returning an owning type like String instead, and possibly mention Cow.
Good point. Updated.
"How can I define a struct that contains a pointer to one of its own fields?" - I think you can actually do this, but it's useless as the struct becomes permanently borrowed (by itself), and so cannot ever be moved.
Do you have some example code that does this? I'd like to provide an example if I can.
"What is the difference between consuming and moving/taking ownership?" - They're actually the same thing. When you call a method which consumes self, there's no requirement that self is dropped, it's simply moved into the method.
You're right. Fixed.
"Using Deref coercions! Strings and Vecs will automatically coerce to their respective slices when referenced" - The term "referenced" is very ambiguous here, maybe make it clear that you mean using &var.
I agree. I've clarified the language.
"How do I do O(1) character access in a String?" - You can: str implements both Index and IndexMut, and so indexing is available via both String and &str. The caveats you mentioned still apply, but rather than getting out nonsense data, indexing will panic if it's not a valid UTF8 boundary.
Good point. I've updated the answer.
"The char type is UCS4" - Actually, it's UTF32, which is subtly different because it disallows values outside the range 0-0x10FFFF, or within the range reserved for UTF16 surrogates. This is necessary to ensure that it can only contain valid unicode characters.
Yup. I copied this answer verbatim from a much older FAQ on the Rust website. It may have been true at one point (I don't know), but you're right that it isn't now.
"Modules and Crates" - Maybe mention that use declarations are always relative to the crate root, rather than the current module, which is different from how name resolution works for everything else. This is one of the most confusing things when first using rust's module system.
I've added an answer addressing this.
"What is "monomorphisation" - C++ programmers will know this as template instantiation. In rust however, it's an implementation detail rather than a language feature.
Good idea. Added.
"How does Rust's ownership system related to move semantics in C++?" - Maybe note that unlike in rust, in C++ destructors are still called after a value has been moved, ie. it's a destructive copy rather than an actual move.
Yup. Added.
"Does Rust have C++-style constructors?" - Mention that methods which construct value are typically named "new".
Added, along with a small example of such a function.
|
Wonderful! This is exactly the input I'm looking for:
Ah, mistake during editing. Fixing now.
Good to know. I've updated my answer accordingly.
Do you know which crate?
Good point. Updated.
Do you have some example code that does this? I'd like to provide an example if I can.
You're right. Fixed.
I agree. I've clarified the language.
Good point. I've updated the answer.
Yup. I copied this answer verbatim from a much older FAQ on the Rust website. It may have been true at one point (I don't know), but you're right that it isn't now.
I've added an answer addressing this.
Good idea. Added.
Yup. Added.
Added, along with a small example of such a function. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Oct 23, 2015
Contributor
Before anything gets merged I do want to note that four questions remain unanswered and commented out in the source code. This does not necessarily need to block merging, but if someone can answer any of these questions before we merge that would be much appreciated. If not, then afterward works.
|
Before anything gets merged I do want to note that four questions remain unanswered and commented out in the source code. This does not necessarily need to block merging, but if someone can answer any of these questions before we merge that would be much appreciated. If not, then afterward works. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Diggsey
Oct 23, 2015
Do you know which crate?
https://crates.io/crates/ordered-float
Do you have some example code that does this? I'd like to provide an example if I can.
Diggsey
commented
Oct 23, 2015
https://crates.io/crates/ordered-float
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Okay, I've updated it with that information. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Nov 4, 2015
Contributor
I think this is ready to merge, unless there are concerns about the specialized styling for the page.
|
I think this is ready to merge, unless there are concerns about the specialized styling for the page. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
|
GuillaumeGomez
reviewed
Nov 5, 2015
brson
reviewed
Nov 5, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
aturon
Nov 5, 2015
Member
cc me. We need to advertise this PR very widely, get the whole community's eyes on it.
|
cc me. We need to advertise this PR very widely, get the whole community's eyes on it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
edunham
Nov 5, 2015
Member
Could this be formatted so each question has an anchor, and I can link to a specific section? I imagine needing to link particular questions to new users quite frequently, and it'd be better to include the section in the URL than to tell them "click here and scrolll"
|
Could this be formatted so each question has an anchor, and I can link to a specific section? I imagine needing to link particular questions to new users quite frequently, and it'd be better to include the section in the URL than to tell them "click here and scrolll" |
brson
reviewed
Nov 5, 2015
brson
reviewed
Nov 5, 2015
nikomatsakis
reviewed
Nov 5, 2015
nagisa
reviewed
Nov 5, 2015
brson
reviewed
Nov 5, 2015
sfackler
reviewed
Nov 5, 2015
mbrubeck
reviewed
Nov 5, 2015
nikomatsakis
reviewed
Nov 5, 2015
sfackler
reviewed
Nov 5, 2015
brson
reviewed
Nov 5, 2015
mbrubeck
reviewed
Nov 5, 2015
nagisa
reviewed
Nov 5, 2015
mbrubeck
reviewed
Nov 5, 2015
sfackler
reviewed
Nov 5, 2015
nagisa
reviewed
Nov 5, 2015
sfackler
reviewed
Nov 5, 2015
nagisa
reviewed
Nov 5, 2015
nagisa
reviewed
Nov 5, 2015
nagisa
reviewed
Nov 5, 2015
nagisa
reviewed
Nov 5, 2015
steveklabnik
reviewed
Jan 7, 2016
steveklabnik
reviewed
Jan 7, 2016
steveklabnik
reviewed
Jan 7, 2016
steveklabnik
reviewed
Jan 7, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
steveklabnik
Jan 7, 2016
Member
@AndrewBrinker thank you so much for putting the work into this. It's awesome.
|
@AndrewBrinker thank you so much for putting the work into this. It's awesome. |
apasel422
reviewed
Jan 7, 2016
apasel422
reviewed
Jan 7, 2016
apasel422
reviewed
Jan 7, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Jan 7, 2016
Contributor
Obviously things aren't quite done yet. I have some more direct feedback to go over, and I need to address @brson's previous points. But I just want to say that this has been a really great process, and I can't wait to get this thing polished and merged. Thanks for all the help and feedback, everyone.
Oh, and no problem @steveklabnik. It's been my pleasure.
|
Obviously things aren't quite done yet. I have some more direct feedback to go over, and I need to address @brson's previous points. But I just want to say that this has been a really great process, and I can't wait to get this thing polished and merged. Thanks for all the help and feedback, everyone. Oh, and no problem @steveklabnik. It's been my pleasure. |
pnkfelix
reviewed
Jan 8, 2016
AndrewBrinker
added some commits
Jan 8, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pnkfelix
Jan 8, 2016
Member
(great job incorporating feedback @AndrewBrinker ; I was especially impressed by the places where I said "oh man this is wrong but I don't know how to fix it" (and I threw up my hands) and you subsequently found a solution, quite quickly!)
|
(great job incorporating feedback @AndrewBrinker ; I was especially impressed by the places where I said "oh man this is wrong but I don't know how to fix it" (and I threw up my hands) and you subsequently found a solution, quite quickly!) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Jan 8, 2016
Contributor
Thanks @pnkfelix! I'm glad you like what I've done. It wouldn't have been possible without all the great feedback from everyone. The current version is much much better than my first draft. It'll be interesting to see how the document evolves over time, and to see what sort of feedback we get once it's up on the site.
@brson, I know you have some style changes you'd like made, and that your plan is to wrap this up yourself (I'm guessing squash down all the commits in this PR). Should I incorporate the style changes here, or is that something you'd like to do?
Also, I am still working on your big list of thoughts. The deref coercion and higher-kinded types answers have been updated, but the rest still need to be addressed properly.
|
Thanks @pnkfelix! I'm glad you like what I've done. It wouldn't have been possible without all the great feedback from everyone. The current version is much much better than my first draft. It'll be interesting to see how the document evolves over time, and to see what sort of feedback we get once it's up on the site. @brson, I know you have some style changes you'd like made, and that your plan is to wrap this up yourself (I'm guessing squash down all the commits in this PR). Should I incorporate the style changes here, or is that something you'd like to do? Also, I am still working on your big list of thoughts. The deref coercion and higher-kinded types answers have been updated, but the rest still need to be addressed properly. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Jan 8, 2016
Contributor
Also, I started adding a bunch of missing links to the API docs at @steveklabnik's suggestion, but I'm not finished yet.
|
Also, I started adding a bunch of missing links to the API docs at @steveklabnik's suggestion, but I'm not finished yet. |
solson
reviewed
Jan 8, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@AndrewBrinker rocks! |
solson
reviewed
Jan 8, 2016
solson
reviewed
Jan 8, 2016
solson
reviewed
Jan 8, 2016
| ### Does Rust allow non-constant-expression values for globals? | ||
| No. Globals cannot have a non-constant-expression constructor and cannot have a destructor at all. Static constructors are undesirable because portably ensuring a static initialization order is difficult. Life before main is often considered a misfeature, so Rust does not allow it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
solson
Jan 8, 2016
Member
This is shaping up to be quite excellent! Thanks to everyone who's been working so hard on this.
|
This is shaping up to be quite excellent! Thanks to everyone who's been working so hard on this. |
AndrewBrinker
added some commits
Jan 9, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Jan 9, 2016
Contributor
Okay, I've now made changes addressing all but the following points of @brson's:
- The exceptions answer still needs a rewrite
- We still don't have an answer on Rust's name (I'm actually not sure what the real explanation is here)
- The "Concurrency," "Macros," and "Debugging" sections are still small (I think this is fine for now. They will almost certainly grow in future revisions based on community feedback).
I am also still going through the entire document adding links to the API docs.
|
Okay, I've now made changes addressing all but the following points of @brson's:
I am also still going through the entire document adding links to the API docs. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
solson
commented on faq.md in ea304ed
Jan 9, 2016
|
This and the above should use |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AndrewBrinker
Jan 9, 2016
Contributor
Okay, I've finished adding the links to the API docs, and I've made the correction suggested by @tsion.
|
Okay, I've finished adding the links to the API docs, and I've made the correction suggested by @tsion. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
brson
Jan 12, 2016
Contributor
@brson, I know you have some style changes you'd like made, and that your plan is to wrap this up yourself (I'm guessing squash down all the commits in this PR). Should I incorporate the style changes here, or is that something you'd like to do?
I'll take care of merging the styles. I am going to open one PR that contains all pending website changes.
I'll take care of merging the styles. I am going to open one PR that contains all pending website changes. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
brson
Jan 12, 2016
Contributor
My previous points have been addressed to my satisfaction (for the most part, see below), and I'm intending to merge this with the other open PRs and my style changes into one fresh PR for landing.
The only remaining big concerns I have about the FAQ are: HKT section, while better, in the first section makes it sound like Rust has HKT by saying that type constructors that exist are KHTs; there's still no Q&A for 'What does "Rust" mean'.
I'm happy to address those in follow ups though.
|
My previous points have been addressed to my satisfaction (for the most part, see below), and I'm intending to merge this with the other open PRs and my style changes into one fresh PR for landing. The only remaining big concerns I have about the FAQ are: HKT section, while better, in the first section makes it sound like Rust has HKT by saying that type constructors that exist are KHTs; there's still no Q&A for 'What does "Rust" mean'. I'm happy to address those in follow ups though. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
brson
Jan 12, 2016
Contributor
Thank you everybody for the amazing reviews and @AndrewBrinker for putting it all together. We're almost done.
|
Thank you everybody for the amazing reviews and @AndrewBrinker for putting it all together. We're almost done. |
AndrewBrinker commentedOct 22, 2015
This commit is the first draft of a new Frequently Asked Questions (FAQ) page for the Rust website. It provides answers for all but 4 of the 130 questions asked by the community, which can be found on the tracking issue #181.
The answers could use some review, as could the design and organization. I've tried to provide clear, concise answers that more often than not point people to the relevant portion of the Rust book.
Thoughts? Changes?