-
Notifications
You must be signed in to change notification settings - Fork 13.3k
doc: forward-port the conditions tutorial + fixup libstd example #10986
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
Conversation
pairs | ||
} | ||
~~~~ | ||
|
||
Note that we could spare a vector allocation by matching directly over the words, like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, if we can avoid an allocation, then why encourage an allocation in the code example? Why not replace the example above with this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that having more generic code would be good for the tutorial. Do you want me to swap it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make sense to me to have two versions of code where you say "this one is better" but you showcase the other one. This suggestion about avoiding allocations should either be dropped or integrated into the other examples in my opinion.
Nice work, thanks! |
[a, b] => pairs.push((from_str::<int>(a).unwrap(), | ||
from_str::<int>(b).unwrap())), | ||
|
||
// Explicitly fail on malformed lines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the whole point of this section to showcase failure? Why remove the one comment pointing it out that this is the error-handling strategy used in this case?
# pos: @mut 0 | ||
# } as @Reader | ||
# } | ||
# } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcrichton Legitimate failure here: the bots want a file with its path path passed as args to test... can I simulate the above with the actual implementation or should I keep the tests xfailed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we've seen what happens when the tests get xfailed, so let's keep them not-xfailed if at all possible. You can take the route of the above code (give a dummy reader) if you want by having mod File
hidden at the top.
Thanks to @huonw for some mentoring. 🍰
…=Manishearth Allow safety comment above attributes Closes rust-lang#8679 changelog: Enhancement: [`undocumented_safety_block`]: Added `accept-comment-above-attributes` configuration.
Thanks to @huonw for some mentoring. 🍰