« first day (2131 days earlier)      last day (1344 days later) » 

12:55 PM
Is there some way to make the following fail if it is an integer?
fn main() {
    let s = "450";
    let x = s.parse::<f32>().unwrap();
    println!("x: {:?}", x); // x: 450.0
}
I could use s.contains("."), but I'm wondering if there's a more idiomatic way? It needs to fail if it's an integer.
 
1:11 PM
@Jason with f32::fract perhaps?
You could also read this answer and the realated comments
 
@PeterVaro Thank you for answering. I came across that thread, but it seems .fract() will give me 0.0 for both 10 and 10.0. It's understandable as to why, after it is has been converted to a float, but it doesn't allow to me differentiate between int and float in a string?
 
Why does it have to be at the "string-state"?
(I fail to understand that bit..)
 
Haha, I have to do some data wrangling unfortunately.
I wish it were different.
 
Well, in that case the proposed constains feels good enough for me -- unless it could take some scientific form, like 1e-10 (I'm not sure about the Debug or the Display implementations' internals for f32 or f64)
Either way, you could check for decimal characters only -- if you must work with strings
 
Yes! I noticed bool might become then-able which would be nice if combined with .contains().
 
that's... actually amazing!!?? ^
 
It is, isn't it?
 
and like, 4M!!
 
I'm so sad that I didn't came up with the idea.. so simple, so easy to produce, yet when it is created like this it is unresistable
 
I.. kinda really want one
 
2:08 PM
We should've built one with Rust on STM32 boards
 
@FélixGagnon-Grenier between you and me: I think I'd like one as well..
 
 
2 hours later…
3:58 PM
@PeterVaro apparently some parts are written in Rust: kickstarter.com/projects/flipper-devices/…
 
@FrancisGagné Here we go then! I feel a bit ashamed for posting this link, talking about a possible Rust alternative yet I didn't care to check the tech-stack :/
 
 
1 hour later…
5:20 PM
I'm trying to modify a crate's code for testing, and the method highlighted here sounds plausibly useful, but I'm unsure where the code is locally (presuming cargo actually stores it locally?)
I don't seem to see a vendor directory in the project's root
 
@FélixGagnon-Grenier if you're trying to test a local version of an upstream crate, you want to use [patch]
 
@FrancisGagné ah that sounds like it! I'd try and modify the build file you gracefully identified for me yesterday!
 
also, dependencies from crates.io are stored in ~/.cargo/registry/
but don't go editing files in there ;)
 
heh, I promise :)
oh. my. god.
so. I er. did not use the latest version of the crate.
disappears in a hole forever
... saving grace: it still takes the latest master from github to compile successfully. thanks @Francis, through all of that the patch part was finally able to get me through it :)
 
5:44 PM
@FélixGagnon-Grenier you're welcome! :)
 
 
2 hours later…
8:05 PM
@Jason if you are doing a lot of parsing try nom
 
@Stargateur thank you! I've heard that crate's name before, I'll give it a look :-)
 
just note that it's a "low level" parsing
 
 
2 hours later…
9:42 PM
@Stargateur also note that it is really difficult to use - but really easy to read the code afterwards :)
 
9:57 PM
@Jason ^^
 

« first day (2131 days earlier)      last day (1344 days later) »