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

Why are IterMut iterator loops allowed to use aliasing &mut references?

pezcore: How can it be possible to borrow self.slice in the expression &mut self.slice on the last line when self.slice is already exclusively borrowed by self? This, again, is a case where you can characterize the reborrow fully by what would also work, pretending this was a borrow of the variable self then projected down to a reference to self.slice. In types, because English can be messy when talking about reference to reference to stuff, I mean: start with self: &'s mut MyIterMut<'a, T>…

Where does ownership and borrowing rules shine?

Levied: Do concepts like ownership and borrowing specifically exist in Rust to prevent UB in multithreaded context? Obligatory link: manishearth.github.io The Problem With Single-threaded Shared Mutability - In Pursuit of Laziness Edit (Jan 2017): I re-discovered Niko’s post which touches on this and reaches for the same realization. I suspect I subconsciously got the idea for this from that post, at least in part. This is a … Over a decade old now, but still perfectly applicable.

Project to install RustUp on Linux, Windows and macOS

I don't know about Mac, but for most Linux distributions this seems quite pointless, since rustup ships as a distro's package that already pulls in all the necessary dependencies via the respective package manager. On my system: > LANG=C pacman -Qi rustup Name : rustup Version : 1.29.3-1 Description : The Rust toolchain installer Architecture : x86_64 URL : https://github.com/rust-lang/rustup.rs Licenses : MIT Apache-2.0 Groups : None Provides : rust cargo rust-nightly cargo-nightly rustfmt…

Project to install RustUp on Linux, Windows and macOS

I am working on a project that allows Rust to be installed on the following operating systems: Linux, Windows and macOS. The aim is to check that the necessary libraries are installed and that rustup is not installed. At the moment, I only have it set up for one Linux distribution, but the plan is to gradually extend it to other distributions, as well as Windows and macOS. I’d like to hear your feedback. I know the code isn’t quite up to scratch yet, but the idea is to create a working…

Is `rust-toolchain.toml` with non-versioned channel such as `stable` a code smell?

MusicalNinjaDad: As for new lints, I think I would be most likely to make a 5 minute PR to set that lint to allow in Cargo.toml and add a linked issue. Thus staying up-to-date on my toolchain and having control over when I address the new lint. I've not yet suffered from this (as far as I can remember) have you had the problem often? It happened a few times to me that a new Clippy version found ways how I can make my code more efficient or easier to read, and usually that was quite helpful.…

Where does ownership and borrowing rules shine?

Actually, I wonder if your real intent was to use references for the iteration as in fn main() { const CLEAR_THE_DECKS: u32 = 42; let mut input = vec![1]; // Code filling in the Vec for &item in &input { if item == CLEAR_THE_DECKS { input.clear() } } } as this gives in the playground the expected error: Compiling playground v0.0.1 (/playground) error[E0502]: cannot borrow `input` as mutable because it is also borrowed as immutable --> src/main.rs:8:13 | 6 | for &item in &input { | - ------ | |…

XDP + userspace TCP for a high-performance proxy?

Hi, I've been working on zeroio. My goal is to build a fast network dataplane in Rust using XDP and a userspace TCP stack, with support for congestion control, SNI/QUIC forwarding and DDoS protection. So far, L7 performance has been quite disappointing compared to just using the kernel TCP stack. Has anyone here tried something similar? I'm wondering if I'm missing something obvious or if userspace TCP just isn't a good fit for this kind of workload. Would love to hear your thoughts.

How do I install packages in Linux using Rust commands?

I need install a packege how to curl in linux, I need to install a package such as Curl on Linux, but the problem is that when it comes to installing it, I don’t know how to enter the superuser password when prompted. Here is the function I’m using. use std::process::Command; pub fn install_curl(package_manager: &str, args: &[&str]) -> bool { Command::new(package_manager) .args(args) .output() .map(|value| value.status.success()) .unwrap_or(false) } Example of command with Arch: sudo pacman -S…

Using clearscreen in Linux and Android (under Termux)

This problem has been solved by the OP. The problem was that in writing the source (for a modified hello world program after using: cargo new hello I wrote hello.rs in that folder, rather than modifying ./src/main.rs and running: cargo build cargo run once I did that, compilation worked after: cargo add clearscreen before this I was explicitly running: rustc hello.rs Thanks for the replies, I cannot afford "the book" yet, learning by reading others and web searches. Been a rough row to hoe…

What's everyone working on this week (48/2026)?

I've been working on koru.do It is an open source workspace for notes, files, tasks and your own AI. It is written in Rust Works fully offline and you can p2p sync with other devices. It has built in OCR support for PDFs and images. You can run your agents inside Koru It has a built in MCP server so you can connect agents and collaborate on notes. The next apps coming are Koru Bots (an alternative to Grok Bots) and p2p collaboration. Please star if you like it Koru in Github

Why are IterMut iterator loops allowed to use aliasing &mut references?

In your example: pub struct MyIterMut<'a, T> { slice: &'a mut [T] } impl<'a, T> Iterator for MyIterMut<'a, T> { type Item = &'a mut T; fn next(&mut self) -> Option<Self::Item> { // Temporarily take the slice. This is really needed only to make some lifetimes match up :( let slice = std::mem::take(&mut self.slice); How can it be possible to borrow self.slice in the expression &mut self.slice on the last line when self.slice is already exclusively borrowed by self? It seems to me from this…

Does anyone actually length-check CStr::from_ptr?

Yeah, something like that maybe. Edit: To clarify, thanks for the code. My hesitance here is more that I have to go through the documentation and re-verify things for safety, re-write my code documentation, things like that. Edit 2: Yeah it's possible to not use CStr but I'm also using CString/CStr to convert to C strings anyway so I might as well use it.

Does anyone actually length-check CStr::from_ptr?

unsafe fn cstr_len(cstr_ptr: *const c_char, max_len: isize) -> Option<usize> { for pos in 0..(max_len + 1) { let current_ptr = unsafe { cstr_ptr.offset(pos) }; let current_char = unsafe { current_ptr.read() }; if current_char == 0 { return Some(pos); // including terminator (to match fn name semantics) } } None } pub unsafe fn cstr_to_string(cstr_ptr: *const c_char, max_len: isize) -> Option<String> { let length = unsafe { cstr_len(cstr_ptr, max_len) }?; let cstr = unsafe {…

Does anyone actually length-check CStr::from_ptr?

The code looks something like this (documentation/SAFETY notes removed, I don't want to clog up this thread): unsafe fn cstr_len_longer(cstr_ptr: *const c_char, max_len: isize) -> bool { for pos in 0..(max_len + 1) { let current_ptr = unsafe { cstr_ptr.offset(pos) }; let current_char = unsafe { current_ptr.read() }; if current_char == 0 { return false; } } true } pub unsafe fn cstr_to_string(cstr_ptr: *const c_char, max_len: isize) -> Option<String> { let too_long = unsafe {…

Does anyone actually length-check CStr::from_ptr?

Jookia: For my own code I'm going to write a length check function that checks the length of a string before passing it to CStr::from_ptr. Wouldn't you have effectively allowed yourself to skip the CStr entirely if you do that. I'm thinking you'll be iterating for i in 0..MAX through each bytes with pointer.add & read then checking for \0 (?) At which point you could slice::from_raw_parts and have a [u8] to convert to utf8?? Or am I missing a simpler way to check

Rolling upgrades in tellus: old code cannot learn a new shape

Yes, it is explicit, but less work than it sounds: A type which never changed needs only an impl Schema; the defaults handle version 0. You keep an old struct only while nodes running the old version may be around, usually just the previous one. After the rollout it can go. Bumping VERSION is one deliberate line: only you know whether a change alters the serialized shape. Nested types need no dispatch of their own. The schema version belongs to the message type, so a change in a nested struct…

GAT Box lifetime problem

the error is the parameter type `P` may not live long enough the parameter type `P` must be valid for the static lifetime...rustcClick for full compiler diagnostic test30.rs(11, 17): consider adding an explicit lifetime bound: ` + 'static` the parameter type `P` may not live long enough ...so that the type `P` will meet its required lifetime boundsrustcClick for full compiler diagnostic test30.rs(11, 17): consider adding an explicit lifetime bound: ` + 'static` lifetime may not live long enough…

Does anyone actually length-check CStr::from_ptr?

Again, though, platform specific. The 32 bit ARMv7 Linux platform I work on uses signed integers in the allocator, so while I have the address space for a bigger than 2 GiB allocation, nothing can actually allocate that much. And a quick experiment shows that if I try and mmap a 2 GiB + 1 page file, I get EINVAL back, despite /proc/self/maps showing that I have 2.5 GiB of contiguous address space available - something (whether it's in libc or the kernel, I don't know) simply won't let me have a…