Skip to content
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

Add grammar in docs for {f32,f64}::from_str, mention known bug. #56217

Merged
merged 6 commits into from
Jan 25, 2019
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/libcore/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,33 @@ macro_rules! from_str_float_impl {
/// * '2.5E10', or equivalently, '2.5e10'
/// * '2.5E-10'
/// * '5.'
/// * '.5', or, equivalently, '0.5'
/// * '.5', or, equivalently, '0.5'
/// * 'inf', '-inf', 'NaN'
///
/// Leading and trailing whitespace represent an error.
///
/// # Grammar
///
/// All strings that adhere to the following EBNF grammar
frewsxcv marked this conversation as resolved.
Show resolved Hide resolved
/// will result in an [`Ok`] being returned:
///
/// ```txt
/// Float ::= Sign? ( 'inf' | 'NaN' | Number )
/// Number ::= ( Digit+ |
/// Digit+ '.' Digit* |
/// Digit* '.' Digit+ ) Exp?
/// Exp ::= [eE] Sign? Digit+
/// Sign ::= [+-]
/// Digit ::= [0-9]
/// ```
QuietMisdreavus marked this conversation as resolved.
Show resolved Hide resolved
///
/// # Known bugs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historically, we haven't mentioned known bugs in the docs, but considering this known bug has existed for years and people keep hitting it, I think it's worth calling it out here.

///
/// In some situations, some strings that should create a valid float
/// instead return an error. See [issue #31407] for details.
///
/// [issue #31407]: https://github.com/rust-lang/rust/issues/31407
///
/// # Arguments
///
/// * src - A string
Expand Down