Servo GTK: a widget to embed Servo in GTK4
Servo, the Rust-based browsing engine spun off from Mozilla, keeps making progress every month, and this made Ignacio Casal Quinteiro wonder: what if we make a GTK widget so we can test Servo and compare it to WebKitGTK? As part of my job at Amazon I started working in a GTK widget which will allow embedding a Servo Webview inside a GTK application. This was mostly a research project just to understand the current state of Servo and whether it was … ⌘ Read more
Linus Says Rust Formatting is “Bass-Ackwards Garbage”
“[Rustfmtcheck] is just ANNOYING. ⌘ Read more
Redox now multithreaded by default
Can these months please stop passing us by this quickly? It seems we’re getting a monthly Redox update every other week now, and that’s not right. Anyway, what have the people behind this Rust-based operating system been up to this past month? One of the biggest changes this month is that Redox is now multithreaded by default, at least on x86 machines. Unsurprisingly, this can enable some serious performance gains. Also contributing to performance improvements t … ⌘ Read more
cargo-subspace: Make rust-analyzer work better with very large cargo workspaces
Let me preface all of this by saying that rust-analyzer is an amazing project, and I am eternally grateful for the many people who contribute to it! It makes developing rust code a breeze, and it has surely significantly contributed to Rust’s widespread adoption.
If you’ve ever worked with a very large cargo workspace (think hundreds of crates), you know that rust-analyzer eagerly builds compile time dependencies (e.g. proc macros) and index … ⌘ Read more
Linux, Rust, & NixOS Use Master Branch, Support Human Slavery
Using the term “Master” in our software projects is racist, right? ⌘ Read more
Ninajirachi’s “I Love My Computer” føles som det rigtige album at skrive embedded rust bluetooth drivere til ⌘ Read more
Ubuntu’s Rust GNU Utils Replacement 17x Slower & Buggy
Canonical plans to replace the battle tested GNU Coreutils with new, untested, Rust-based replacements. ⌘ Read more
Mathieu Pasquet: slixmpp v1.11
This new version includes a few new XEP plugins as well as fixes, notably
for some leftover issues in our rust JID code, as well as one for a bug that
caused issues in Home Assistant.
Thanks to everyone who contributed with code, issues, suggestions, and reviews!
CI and buildNicoco put in a lot of work in order to get all possible wheels built in CI. We now have manylinux and musl builds of everything doable within codeberg,
published to the codeberg pypi repo, and published on pypi. … ⌘ Read more
從被噴 “假開源” 到登頂 GitHub 熱榜,RustFS 開源項目上演王者歸來!
故事的序幕,在 2024 年 1 月的 GitHub 上悄然拉開。當時,一個名爲 RustFS 的開源項目橫空出世,號稱要做一個基於 Rust 的企業級分佈式存儲系統,旨在成爲 MinIO 的一個開源替代品。這個口號直接把大家吊成了 “翹嘴”,但左等右等,結果一年了還只有一份 README 文件,就是不見源碼。一時間,開源社區質疑聲四起:“假開源”、“PPT 開源”、“光說不練”。面對壓力,Rus ⌘ Read more
Okay, now this is a very interesting Rust feature:
https://blog.rust-lang.org/2025/07/03/stabilizing-naked-functions/
This (and inline assembly) makes Rust really interesting for very low-level stuff. 🥳
Option and error handling. (Or the more complex Result, but it’s easier to explain with Option.)
@lyse@lyse.isobeef.org lol – I explicitly kept them in there so that the code is easier to understand for non-Rust people 🤪😂
Okay, here’s a thing I like about Rust: Returning things as Option and error handling. (Or the more complex Result, but it’s easier to explain with Option.)
fn mydiv(num: f64, denom: f64) -> Option<f64> {
// (Let’s ignore precision issues for a second.)
if denom == 0.0 {
return None;
} else {
return Some(num / denom);
}
}
fn main() {
// Explicit, verbose version:
let num: f64 = 123.0;
let denom: f64 = 456.0;
let wrapped_res = mydiv(num, denom);
if wrapped_res.is_some() {
println!("Unwrapped result: {}", wrapped_res.unwrap());
}
// Shorter version using "if let":
if let Some(res) = mydiv(123.0, 456.0) {
println!("Here’s a result: {}", res);
}
if let Some(res) = mydiv(123.0, 0.0) {
println!("Huh, we divided by zero? This never happens. {}", res);
}
}
You can’t divide by zero, so the function returns an “error” in that case. (Option isn’t really used for errors, IIUC, but the basic idea is the same for Result.)
Option is an enum. It can have the value Some or None. In the case of Some, you can attach additional data to the enum. In this case, we are attaching a floating point value.
The caller then has to decide: Is the value None or Some? Did the function succeed or not? If it is Some, the caller can do .unwrap() on this enum to get the inner value (the floating point value). If you do .unwrap() on a None value, the program will panic and die.
The if let version using destructuring is much shorter and, once you got used to it, actually quite nice.
Now the trick is that you must somehow handle these two cases. You must either call something like .unwrap() or do destructuring or something, otherwise you can’t access the attached value at all. As I understand it, it is impossible to just completely ignore error cases. And the compiler enforces it.
(In case of Result, the compiler would warn you if you ignore the return value entirely. So something like doing write() and then ignoring the return value would be caught as well.)
@prologic@twtxt.net I’m trying to call some libc functions (because the Rust stdlib does not have an equivalent for getpeername(), for example, so I don’t have a choice), so I have to do some FFI stuff and deal with raw pointers and all that, which is very gnarly in Rust – because you’re not supposed to do this. Things like that are trivial in C or even Assembler, but I have not yet understood what Rust does under the hood. How and when does it allocate or free memory … is the pointer that I get even still valid by the time I do the libc call? Stuff like that.
I hope that I eventually learn this over time … but I get slapped in the face at every step. It’s very frustrating and I’m always this 🤏 close to giving up (only to try again a year later).
Oh, yeah, yeah, I guess I could “just” use some 3rd party library for this. socket2 gets mentioned a lot in this context. But I don’t want to. I literally need one getpeername() call during the lifetime of my program, I don’t even do the socket(), bind(), listen(), accept() dance, I already have a fully functional file descriptor. Using a library for that is total overkill and I’d rather do it myself. (And look at the version number: 0.5.10. The library is 6 years old but they’re still saying: “Nah, we’re not 1.0 yet, we reserve the right to make breaking changes with every new release.” So many Rust libs are still unstable …)
… and I could go on and on and on … 🤣
@movq@www.uninformativ.de Hahaha 😂 This is gold! I’ve been following along with our ramblings on Rust. What’s it gone and done to you now? 🤔 I don’t think I can ever be friends personally, I feel “too stupid” to learn Rust 🤣
Fuck me sideways, Rust is so hard. Will we ever be friends?
fn sub(foo: &String) {
println!("We got this string: [{}]", foo);
}
fn main() {
// "Hello", 0x00, 0x00, "!"
let buf: [u8; 8] = [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x00, 0x00, 0x21];
// Create a string from the byte array above, interpret as UTF-8, ignore decoding errors.
let lossy_unicode = String::from_utf8_lossy(&buf).to_string();
sub(&lossy_unicode);
}
Create a string from a byte array, but the result isn’t a string, it’s a cow 🐮, so you need another to_string() to convert your “string” into a string.
- https://doc.rust-lang.org/std/string/struct.String.html#method.from_utf8_lossy
- https://doc.rust-lang.org/std/borrow/enum.Cow.html
I still have a lot to learn.
(into_owned() instead of to_string() also works and makes more sense to me, it’s just that the compiler suggested to_string() first, which led to this funny example.)
@lyse@lyse.isobeef.org Rust is so different and, at the same time, so complex – it’s not far fetched to assume that I simply don’t understand what’s going on here. The docs appear to be clear, but alas … is it a bugs in the docs? Is it a lack of experience on my part? Who knows.
By the way, looks like there was a bit of a discussion regarding that name:
So I was using this function in Rust:
https://doc.rust-lang.org/std/path/struct.Path.html#method.display
Note the little 1.0.0 in the top right corner, which means that this function has been “stable since Rust version 1.0.0”. We’re at 1.87 now, so we’re good.
Then I compiled my program on OpenBSD with Rust 1.86, i.e. just one version behind, but well ahead of 1.0.0.
The compiler said that I was using an unstable library feature.
Turns out, that function internally uses this:
https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.display
And that is only available since Rust 1.87.
How was I supposed to know this? 🤨
@prologic@twtxt.net Yeah, it’s difficult, you often don’t get what you’d expect. They also make heavy use of 3rd party libraries. IIUC, for random numbers, they refer to this library. I’ve read many times that the Rust stdlib is intentionally minimalistic (to make it easier to maintain and port and all that).
I’m struggling with this, using 3rd party libs for so many things isn’t really my cup of tea. I’ll probably make my own tiny little “standard library”. It’s silly, but I don’t see any other options. 🤷
@movq@www.uninformativ.de LOL 🤣 I don’t think I could ever take Rust seriaujly 🤦♂️
淺析 rust 大明星 Tokio
Tokio 可以說是 rust 中最熱門的庫,對於異步與併發進行了很好的支持。大多數基於 rust 的開源框架都使用到了 Tokio,因此在介紹這些實現開源框架時經常會被問到:底層的異步和併發是怎麼實現的?我只能回答:底層的異步和併發都是由 Tokio 控制的。這顯然不是一個令人滿意的回答。因此本文章將對於 Tokio 的基本方法和底層邏輯進行分析。概述一句話概括 Tokio 可以理解成一個 “ ⌘ Read more
深入 Biome — 現代 Rust 前端工具鏈
Biome 簡介Biome 是一個基於 Rust 開發的前端工具鏈工具,它提供了完善的 Analyzer / Linter / Formatter 的能力支持。目前 Biome 提供了 JS、TS 、JSON/JSONC 以及 CSS 和 GriftQL 等語言的支持。在 Linter 方面,目前 Biome 內置支持了約 320 條以上規則支持 (參考: https://next.biomejs ⌘ Read more
I wanted to port this to Rust as an excercise, but they still have no random number generator in the core library: https://github.com/rust-lang/rust/issues/130703
I Learned Rust In 24 Hours To Eat Free Pizza Morally
This is a satirical tech story. For readers who prefer the text version, it’s provided below.
I Learned Rust in 24 Hours to Eat Free Pizza Morally
This is not just a story about pizza. As a recent Phoronix article explains,
the Linux Rust subsystem got into major drama because of my humble quest.
Well, here’s my side of the story, with every kernel of truth exposed.
A Moral Quest for Pizza
Des … ⌘ Read more