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

Should matches! allow unused bindings?

Thinking about it a bit more, I believe it’s incredibly rare to want to create a new binding with an ALL_CAPS name; essentially every time that occurs the user’s intention is likely to refer to a constant but either there’s a typo or the name is not imported. For the latter case it would be good to look up type-matching constants in accessible scopes and to suggest importing one if found. This case of manually moving a const to another module, accidentally changing the meaning of a pattern, is…

What's actually hard about migrating C++ to Rust?

MASHMARO2718: What I'm wondering is whether preserving behavior this explicitly is actually something people care about in practice. I wonder what you mean by that. I would have thought that preserving the behaviour is the whole point of such a translation. I can't help thinking that trying to do a straightforward almost line by line translation of C++ to Rust is never going to work well if the original code makes use of classes and inheritance etc. Rather one needs to extract the algorithmic…

What's actually hard about migrating C++ to Rust?

MASHMARO2718: I'm curious what you think about this approach. Do you see any fundamental problems with separating the two stages like this? I think the idea you're going for is that you'll be able to incrementally port small parts of the C++ code to Rust, but I'm not sure this is viable or desirable as it requires refactoring your data structures to be Rust-compatible anyway. At that point you might as well just use FFI.

What's actually hard about migrating C++ to Rust?

Thanks! The inheritance issue is particularly interesting. I'm actually taking a two-stage approach. Rather than generating idiomatic Rust directly, I first translate C++ to run on a checked memory emulator written in Rust, then gradually remove the emulation wherever possible. By developer decisions, I mean that when the translator can't determine the intended behavior, it stops rather than guessing. Those decisions are recorded and reused to minimize human intervention. The idea is to…

What's actually hard about migrating C++ to Rust?

Yeah, that's actually why I ended up taking a slightly different approach. Instead of trying to map C++ pointers and ownership directly onto Rust's borrowing rules, I built a checked memory emulator in Rust. The translated code initially operates on this emulated memory rather than relying on Rust's native references to represent C++ pointers. The next step is to gradually remove the emulation wherever possible and recover ordinary Rust code. So I'm effectively separating behavior preservation…

What's actually hard about migrating C++ to Rust?

The parts I found difficult when I ported Schubfach algorithm[1] were the classes where inheritance was used to reduce the amount of code (simple and double-precision code). It wasn't easy to find an approach in Rust that was convenient and solid. Another one was guaranteeing the safety of the pointer-based code filling the buffer. I made that part in safe code, but I'm having second thoughts. I initially did that for the performances, but I'm not sure it'd actually have a significant impact if…

What's actually hard about migrating C++ to Rust?

Has anyone here tried migrating a C++ codebase to Rust? I'm curious about how you dealt with subtle changes in behavior during the migration. I've been experimenting with C++ to safe Rust translation lately, and the more I work on it, the more I feel like syntax is the easy part. Things like undefined behavior, integer overflow, and iteration order are much more interesting (and painful), especially when the translated code compiles and runs but gives slightly different results. One approach…

Should matches! allow unused bindings?

johnbchron: I guess my question is this: is this something that would be accepted into Rust if I were to pursue adding it? I'd be willing to attempt building it if so. What are the criteria under which lints like this are evaluated for acceptance? The easiest way to find out is to open an issue and flag this as a Diagnostics Issue (you'll get prompted for what type of issue), linking back to this thread, while also explaining the pitfall you see with the existing diagnostics and what change…

Feedback wanted: HookForge, a webhook delivery service (Tokio, Axum, SQLx, Postgres)

Thank you, @Anlis, this is a really useful list! You're right about the body limit: my check only runs after the whole body is read, so I'll move it to Axum's built-in limit layer so oversized requests are rejected before they're parsed. My plan: Quick fixes: server address from the environment, tokio::time::interval in the reaper, include the reaper in graceful shutdown, and handle SIGTERM for Docker. Body limit via Axum's limit layer. FromRow structs and query_scalar instead of tuples, and…

How can I avoid create an object every single time I running a program?

I'm new in Rust and I'm working on simple CLI program, so I have a problem. The problem is I create a new object every single time when I run a program but I want to load from JSON. I don't know how to implement it because another part of my code using this object to manipulate with others things in program. This is the part of my main file: fn main() { let mut new_user = Profile::new(); loop { println!("=== MENU ==="); println!("1 - show profile"); println!("2 - add hours"); println!("3 -…

Can images linked from README.md be shown on crates.io/docs.rs?

The change to make a readme that strips out images and inserts links to elsewhere or some other placeholder could be done mechanically. Even with a sed script if you took some care about how you formatted the markdown file. That wouldn't work if you want to rewrite and reflow the text to avoid the mention of the images entirely, but it would work if you are okay with something like "please see the readme in the repo to see images"

Project to install RustUp on Linux, Windows and macOS

It can be an interesting project, since Rust provides too many options how it should be installed. Currently I have a complete mess, like some machine use a night build versions, some production, but old, some can build on Windows without any additional installation, some requires link.exe. So certainly I will watch your efforts until they will shape your project in a powerful tool.