Conversation
|
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
src/libstd/num/f32.rs
Outdated
There was a problem hiding this comment.
I think this should be Returns NaN. (with an s and a ‘.’)—the indicative style is recommended over the imperative.
(Same thing for the others below.)
src/libstd/num/f32.rs
Outdated
There was a problem hiding this comment.
Previously didn't specify exponents base (2? 10? 7? e?). I had to figure out which one worked to recover the original number.
|
You could document the trait itself rather than this specific implementation of it, no? |
|
I don't mind documenting the trait. I was thinking there weren't any examples of traits being documented directly: |
11cf2bc to
cd2c941
Compare
|
Examples shouldn't break if you add a sign somewhere so prefer assigning to variables before using them: // Should prefer
let f = 2.0f64;
f.powi(2);
// over
2.0f64.powi(2);
// because
-2.0f64.powi(2);
// gets parsed as
-(2.0f64.powi(2));
// when the desired is
(-2.0f64).powi(2);
// but this works properly
let f = -2.0f64;
f.powi(2);Note: #22105 ran into this. |
|
Yes, we usually document the trait, not the specific implementation. This seems good though, thanks! would you mind squashing? r=me after |
|
Got a few left but sure. |
|
Do you want me to just wait until you've got more? I assumed this was ready, if not, I'm happy to hold off. |
|
Yeah. I've got another commit incoming. I'll squash after. I got most everything, maybe skipping deprecated and possibly a few unstable. I'll change the title from WIP when it's ready. |
|
Cool, thank you |
c8aac6c to
396244d
Compare
|
@steveklabnik This depends on #22076 merging. It won't pass |
396244d to
fb5d9da
Compare
src/libstd/num/mod.rs
Outdated
There was a problem hiding this comment.
How a float is encoded needs a good reference. This link is probably wrong and is mainly so I remember. Reposting so it's not hidden.
There was a problem hiding this comment.
Deferred to #22152 . Just referred to the float section of the reference for now.
fb5d9da to
208e9bc
Compare
|
@steveklabnik Seems pretty good. Needs #22076 though so gotta wait until that lands. I'll do r= after that merges and |
|
Rebased this commit back to tip. Should be mergeable. Didn't retest. |
|
no rollup as this is a big diff |
|
⌛ Testing commit 1a133f3 with merge b603823... |
Some examples for `std::num::Float` ~~This is WIP for making examples for `f32`. This probably won't pass `make tidy` and I'm not sure which `f32` needs documentation. rust-lang#22025 shows 2 sets of `f32` which seems split between `core` and `std`. I'm not sure which should be documented but I started doing a couple from `std`. Easy to move if that's where they go...~~ ~~Gotta build it eventually to actually see if the docs actually appear where I think they will or if I'm just disillusioned.~~ cc @steveklabnik
|
💔 Test failed - auto-win-32-nopt-t |
|
@bors: retry |
|
⌛ Testing commit 1a133f3 with merge 4087e5b... |
|
💔 Test failed - auto-win-32-nopt-t |
|
@bors: retry |
|
⌛ Testing commit 1a133f3 with merge 886aca4... |
|
💔 Test failed - auto-win-64-nopt-t |
|
@bors: retry |
|
⌛ Testing commit 1a133f3 with merge c34229c... |
|
💔 Test failed - auto-linux-64-nopt-t |
|
@bors: retry |
|
⌛ Testing commit 1a133f3 with merge 4b92061... |
|
💔 Test failed - auto-linux-64-x-android-t |
|
@bors: retry |
|
⌛ Testing commit 1a133f3 with merge 77988b5... |
|
💔 Test failed - auto-linux-64-opt |
Some examples for
std::num::FloatThis is WIP for making examples forf32. This probably won't passmake tidyand I'm not sure whichf32needs documentation. #22025 shows 2 sets off32which seems split betweencoreandstd. I'm not sure which should be documented but I started doing a couple fromstd. Easy to move if that's where they go...Gotta build it eventually to actually see if the docs actually appear where I think they will or if I'm just disillusioned.cc @steveklabnik