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

Thryve: a multithreading task engine in Rust, with a write-up and examples

I've been working on Thryve: a multithreading task engine that is written in Rust with a C API. Plugins, self-contained parts of a program that serve a purpose, send tasks; observers, which listen for events, receive notifications; and the engine runs the tasks on one pool of worker threads. Plugins can interact with each other in a cohesive but decoupled manner, and observers can process notifications and send tasks based on what they received. The decoupling of plugins allows plugins to not…

TWiR quote of the week

And Is there a tool for automatically transpossing my module structure? there was some "reply as new topic button" that'd be useful for starting off-topic discussions, but i do not know where it went. A little later moving to a meta level by taking the off-topic discussion to a off-topic discussion of the off-topicness of the off-topic discussion (I think ...)

Notes from decoding and writing .fig design files in Rust

I've been writing a native interface design tool in Rust, and the part that taught me the most was the file format, so I wanted to share a few notes in case they help anyone parsing a binary format they don't control. A .fig file is usually a ZIP holding canvas.fig, meta.json and an images/ folder. Some files skip the ZIP. canvas.fig starts with the bytes fig-kiwi and a little-endian u32 version (I write 106), followed by compressed chunks: first a Kiwi schema, then a message encoded with that…

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

boomshroom: There are two useful shifts: masking shifts and unbounded shifts. Are masking shifts ever actually useful? I can't think of any such situation. That's different from wrapping arithmetic where at least uN::MAX + 10 - 10 produces the infinite-precision-correct value. (Maybe they're slightly cheaper that a cmov for the unbounded one, but that's still not useful to me.)

Is a personal Rust learning diary appropriate on this forum?

I wouldn't mind this. A forum is after all a place for people to gather, whether it's for mutual help, collaboration, inspiration, feedback, or just to have fun. It is not my place to prescribe the forum's purpose, and the moderators really doesn't either. Though you don't see it now, it was not so long ago that this place flourished with far more newbie questions. This was recently noted: Update forum guidelines/rules to prohibit posting unmarked AI-generated post content? I was wondering…

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

jdahlstrom: Do they?! I’d wager that the majority of C or C++ programmers don’t know either that shifting by k>=N is undefined behavior or that the actual HW behavior on many archs is k&(N-1). Yeah. The article linked doesn't actually say programmers expect it. It just says that there do exist C++ programs that end up relying on this undefined behavior behaving a certain way. But that's always true for every observable behavior no matter how arcane. It doesn't mean programmers wanted such…

Is a personal Rust learning diary appropriate on this forum?

Hello everyone! I recently started a Rust learning diary on this forum, but I received a comment suggesting that a personal blog might be more appropriate. That made me curious about what the community thinks. I can imagine arguments on both sides. Possible arguments against it: Every time I update my diary, the topic moves back to the top of the forum. This could create unnecessary noise for people looking for technical questions and discussions. Possible arguments in favor of it: Sharing a…

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

There are two useful shifts: masking shifts and unbounded shifts. Masking shifts do what the current badly named "wrapping" shifts do and are generally faster, while unbounded shifts are a little slower, but more mathematical. A masking shift by a negative value should do what it currently does: mask the shift value to the required size, which also forces it to be positive. An unbounded shift by a negative value should shift in the other direction, because x.unbounded_shl(y) = floor(x * 2^y) %…

Is there a tool for automatically transpossing my module structure?

MOCKBA: What's a language of that? Already answered but rather than give you a fish, I will teach you a tiny bit of fishing. The code is a shell script. Notice the #! (shebang) on the first line. Schard: #!/usr/bin/env python3 On nix systems if the file is executable, you can execute it without calling python3 directly. Those shebang lines are neat. You put one at the front of a script and your OS / shell will open the interpreter for you when you run the script. Exercise for the ambitous : can…

Program scope unique structs (mutable flavored)

mordecai.brain.leak: but const looks to be compile-time determined Also FYI, when you use a const, it's like you pasted the definition into the use site -- every use is a new value, not a reference to some global value. const V: Vec<u32> = Vec::new(); fn main() { let mut a = V; a.push(0); let mut b = V; b.push(1); println!("{:?}", (a, b)); // ([0], [1]) }

Program scope unique structs (mutable flavored)

(A tangential reply about how to think about Rust, not specific to your particular question.) mordecai.brain.leak: I hadn't considered mutex in a single-thread context. So if I'm understanding, Static hates being mutable, because reading a mutable static is considered unsafe (which seems reasonable), but Mutex/OnceLock/RwLock gets around that by having the type used in Static presented as immutable while interior mutability allows it to be changed in a controlled manner during runtime? I…

Program scope unique structs (mutable flavored)

mordecai.brain.leak: So if I'm understanding, Static hates being mutable, because reading a mutable static is considered unsafe (which seems reasonable), but Mutex/OnceLock/RwLock gets around that by having the type used in Static presented as immutable while interior mutability allows it to be changed in a controlled manner during runtime? I recommend not thinking about it as “getting around”. In order to have safe, global, mutable state, something needs to control access to that state to…

Installing the rust-dev component gives you 2 versions of rustc_hash

Hello, I'm trying to use the rust-dev component where I use rustc_hash, and when I do cargo build I get the following error: error[E0464]: multiple candidates for `rmeta` dependency `rustc_hash` found --> src/main.rs:11:1 | 11 | extern crate rustc_hash; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: candidate #1: ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_hash-bb5b7ec98e3e247f.rmeta = note: candidate #2: ~…

Program scope unique structs (mutable flavored)

Dang, fast and thorough answer, thank you. I hadn't considered mutex in a single-thread context. So if I'm understanding, Static hates being mutable, because reading a mutable static is considered unsafe (which seems reasonable), but Mutex/OnceLock/RwLock gets around that by having the type used in Static presented as immutable while interior mutability allows it to be changed in a controlled manner during runtime? I apologize for the mess, but is this along the lines of what you're saying…