It is well supported in all browsers and operating systems. At least VS Code and IntelliJ support it, and even some terminals.
I don’t understand the “serde2” issue. Isn’t “someusername/serde” strictly worse than “serde2”?
GitHub being the only auth provider is something the maintainers wanted to fix, but didn’t have enough bandwidth to implement. I think they would welcome contributions!
If all you do in the Err(e) => ...
match arm is returning the error, then you absolutely should use the ?
operator instead.
If the match arm also converts the error type into another error type, implement the From
trait for the conversion, then you can use ?
as well.
If you want to add more information to the error, you can use .map_err(...)?
. Or, if you’re using the anyhow
crate, .with_context(...)?
.
I can’t remember ever needing more than two question marks (??
), and even that is very rare in my experience.
It gives you more type safety, because you use a ProxyᐸFooᐳ
instead of just usize
.
Actually, it’s not a package repository (it doesn’t store crates), it’s “just” a website to display metadata from crates published on crates.io. It also shows certain information from docs.rs, GitHub, rustsec.org, etc, and has many useful features that the crates.io website lacks, including a pretty good full-text search.
“secure” is relative. They may not be e2e encrypted, but they are still encrypted via TLS, like any HTTPS traffic. It’s the same encryption used for online banking. If you care about your instance admin being able to read your messages, you should use Signal or a Matrix client though.
But remember that only a few years ago, almost nobody used e2e encryption, and it wasn’t much of an issue.
Thank you, too!
That doesn’t solve the issue that there are too few contributors. Requiring a review doesn’t ensure that someone reviews the code.
On GitHub, everybody has the ability to review pull requests, even you. But there still aren’t enough volunteers who review PRs.
Discriminant is irrelevant and you’re not supposed to fuck with it
It matters because the conversion between i32 and the Result is only “free” if they have the same layout (which they do not, because of the discriminant). So a more costly conversion method is required.
And there is zero reason to use unsafe/transmute for this.
You are right, because the compiler is able to optimize your code quite well. However, if that optimization were to break at some point (as there is no guarantee that an optimization will continue to work in the future), it would become less efficient.
This is not possible, because Rust still stores a discriminant even when the enum values don’t overlap.
As far as I can tell, the only situation where Rust doesn’t store a discriminant is when either the Ok
or Err
variant is zero-sized, and the other variant has a niche. So, Result<(), ErrorEnum>
can be represented as an integer, but Result
can not.
You can still use enums, and implement simple conversions like this:
#[repr(i8)]
pub enum Error {
E1 = -1,
E2 = -2,
E3 = -3,
E4 = -4,
}
#[repr(i8)]
pub enum Success {
S0 = 0,
S1 = 1,
S2 = 2,
S3 = 3,
}
pub type LibResult = Result;
pub fn number_to_result(value: i32) -> Option {
match value {
-4 ..= -1 => Some(Err(unsafe { std::mem::transmute(value as i8) })),
0 ..= 3 => Some(Err(unsafe { std::mem::transmute(value as i8) })),
_ => return None,
}
}
pub fn result_to_number(res: LibResult) -> i32 {
match res {
Ok(value) => value as i32,
Err(error) => error as i32,
}
}
P.S. Sorry that the generics aren’t displayed due to Lemmy’s bad santiziation.
True, code for critical IT infrastructure should always be reviewed. But from what I understand, this is difficult because there is one full-time developer (paid by the Rust Foundation) and a small number of volunteers, who don’t have the time to review all the employee’s changes.
When I searched “bitcoin”, I found the bitcoin crate, but I had to scroll down a bit.
I can recommend Lua. It is easy to learn, and easy to embed in a Rust program. With LuaJIT, it should be pretty fast, too.
Of course you can also embed a JavaScript runtime, but then your executable will probably be 50 MB larger. And I’m not a fan of Python.
The reddit thread has some interesting discussion, and a solution using no SIMD intrinsincs that is more than 200x faster, by using .chunks_exact()
, and letting the compiler auto-vectorize it.
Fully agree with what you said. There are still just as many passionate people fascinated by computers in the youngest generation as there are in older generations. It’s just that the sheer number of programmers has made them less visible in recent years.
Also, one thing the article misses is that programming 8 hours a day and then continuing to program in your spare time is not healthy for many people. People are different, and there are some who can do it without negative consequences, but for others it can lead to burnout, especially if they also have a family to take care of or other issues to deal with. I used to do a lot of programming in my spare time when I was in college. Now that I have a 40-hour-a-week job, I’ve learned that I need to be careful how much energy I spend, and I don’t do as much open source work because I need a lot of my free time to rest and recharge.
It seems like the article was renamed, so the URL changed to https://nnethercote.github.io/2023/07/11/back-end-parallelism-in-the-rust-compiler.html
Thanks!
Piping in a shell script should be doable, it just hasn’t been requested yet.