-
Notifications
You must be signed in to change notification settings - Fork 659
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
Various code improvements #777
Various code improvements #777
Conversation
I also have the feeling that constants like |
There's mixed use of
Good idea. |
The nice |
What's to prevent you from creating a const out of |
That's the same as defining |
If you're defining time in 1 sec chunks the |
I think I see what you guys mean, take a look at da1eded. It compiles but still needs testing. Also let me know about |
I guess my nitpick is that if |
In Rust, values from non-static functions cannot be assigned to a constant. |
Weird that something that would never change, the system's value for a sec, can't be be assigned to a constant? |
It's being changed in Rust nightly but that won't be in |
Crusty old Debian stable,lol!!! |
"Calculating" would be the wrong word here. I'm pretty sure the compiler would optimize it in a way that hasn't more overhead than using a
I don't think that's true. Every
Honestly, I don't know. Maybe search for it in the internet, we're certainly not the only ones who wonder what's better. |
I'm not so sure about that? The compiler can't even optimize a "round to even" situation to not take twice the CPU,lol!!! |
Plus if you could do a const it would look a Hell of a lot cleaner. |
Look: https://godbolt.org/z/E9GrbTox6. The compiler doesn't even generate code for the second function because it knows they're the same.
Agreed. But you can do. |
I was just poking fun. You know a lot more about it then I do,lol!!!
Then we should do. By "we" I mean we in the royal sense, as in @roderickvd should do,lol!!! |
Honestly I didn't even try, but now see that this works so I'll get on it: use std::time::Duration;
const TIMEOUT: Duration = Duration::from_secs(1);
fn main() {
println!("{:?}", TIMEOUT);
}
Man, huge can of worms. I don't particularly care either way, I just want to make them consistent. I'm fine with changing my proposal if anyone thinks that'd be better. Otherwise if no one has an opinion on this, might as well stick with it.
Edit: handy website, learned something today. |
I would stick to |
Here you go.
Thanks for the push into this direction. Using |
If there are no further comments, or people who need more time, I plan on merging this evening. Will merge |
You could write the comments for the constants above the constants and make rustdoc comments out of it |
@Johannesd3 this what you had in mind? |
No, I meant those in audio/src/fetch/mod.rs |
🤦♂️ this should be it then. Intend to squash merge when CI passes. |
This is a collection of code improvements:
std::u16::MAX
constantsFromStr
for fallible&str
conversions everywhereas_ref().map()
calls intoas_deref()
Duration
for time constants and functions