XIO

xWire

Posts from every feed QUEST has found across the web — blogs, news, podcasts, channels and more.

The Rust Programming Language Forum - Latest posts

Latest posts

Program scope unique structs (mutable flavored)

mordecai.brain.leak: There will only ever be one instance of StateVector in existence for the life of the program. This requirement, all by itself, implies some amount of global state, i.e. a static item. The sole instance of StateVector is constructed at runtime, so any reference to it will either be None (if referenced before it is constructed) or a valid StateVector. Okay, so you need some kind of (checked) interior mutability. If it were just initializing once, then you would use a…

Program scope unique structs (mutable flavored)

Apparently I've been playing a game with myself to see how many times I can answer my own questions in the process of figuring how to phrase them correctly enough to be understandable. Regardless, I still haven't found a firm 'does this exist' in my efforts this time, so I thought it might be worth posting to ask. The thought is that it would be convenient for my purposes to have a struct, say StateVector, that holds some arbitrary number of values or sub structures, that: There will only ever…

Why does shifting right by a negative amount not shift left?

Shifts have been around for so long in the language that they probably predate the design philosophy that would prefer a cast there. The language wasn't always quite as explicit, and even to this day some people still are surprised by the lack of integer promotion in other places. Presumably back in the day somebody decided that avoiding casts when computing shifts was worth the potential confusion. I can't find anything in github after a cursory search for it, though. Constant negative shifts…

Why does shifting right by a negative amount not shift left?

miro: Rejecting code at compile time has no runtime cost, Right operand is not constant in shift. Language where it have to constant is not Rust. miro: The compiler can just issue a error for "you're shifting by i32, that needs to be a u32/u64". For the value that doesn't exist at compilation time? How would that work? Even u32/u64 may overflow…

Why does shifting right by a negative amount not shift left?

khimru: ou would need to add check to every place where shift is used. And shift is incredibly common and cheap operation. What makes sense for slow division is not the right fit for shifts… Rejecting code at compile time has no runtime cost, The compiler can just issue a error for "you're shifting by i32, that needs to be a u32/u64".

Weird download spike on a brand new crate, what's going on?

Funny enough, I had the exact same thought while reading the first paragraph of your message. An opt-in "bot" flag would be incredibly useful, but it definitely feels like an utopia. The people running mirroring services or research crawlers are probably not going to bother adding a special flag to their automated requests just to be nice. I was actually thinking that a User-Agent approach might be more practical. If crates.io could distinguish between something like Cargo/1.85.0 (organic) and…

Weird download spike on a brand new crate, what's going on?

This is normal (unfortunately). I don't know what the exact cause is, but my guess is that there are a bunch of organizations mirroring everything on crates.io. Backup/archive purposes maybe. I've seen a few people mention that they are doing research on crates.io, so that might be a few of them. Like I said, I don't actually know, but just be prepared for this behavior when you publish a new crate. I once suggested that there should be an opt-in "bot" flag that would simply cause the download…

Weird download spike on a brand new crate, what's going on?

Okay, so I published this crate called closed about a week ago. It's basically std::function for Rust if anyone's curious. I haven't done any marketing at all — no Reddit, no Twitter, zero. Just pushed 8 versions fixing stuff up. Right now it's sitting at around 2.5k total downloads. But then I looked at the crates.io stats and saw this: Out of nowhere, I got ~1'600 downloads in a single day on Nov 7th. It's a nearly vertical line. I know docs.rs and regular CI pipelines pull crates, but they…

Efficient Arc

I could imagine a version of Arc that always reports a fixed count for ZSTs, like what we do for Vec::capacity, and if it's not needs_drop then the existence of clones or not doesn't matter. It's not something an external crate could produce as a "real std::Arc" though. Such an Arc would also not be able to maintain proper ptr_eq connections among clones.

Cargo formater command not working for me

All you need to do is create a project using `cargo`; the `cargo init` command will generate the entire structure you need. This command creates the necessary directories for you. You can also use `cargo new `; this command creates a new project and the folder structure. After creating the project with `cargo`, use this command: `cargo run`; this will get everything ready.