#rustlang
✍️ New watchexec-focused cohost page and a big recap + story of the recent Watchexec releases: https://cohost.org/watchexec/post/3818997-watchexec-library-3
#rust #rustlang
#rustlang folks up for a question?
I tried to convert a .fold() into a .reduce(), but it didn't work and I don't understand why. Math on shared references to ints seems to work in .fold, but not in .reduce?
fn main() {
let v = vec![1, 2, 3, 4];
// works
println!("{:?}", v.iter().fold(0, |acc, e| e + acc));
// fails: expected `&{integer}`, found integer
println!("{:?}", v.iter().reduce(|acc, e| e + acc).unwrap());
// changing to .into_iter() works
}
All I wanna do is write #rustlang
Found couple more opportunities to optimise serde-wasm-bindgen's deserialization. Up to 24% in struct-heavy benchmarks!
Released as serde-wasm-bindgen 0.6.2. https://github.com/RReverser/serde-wasm-bindgen


I just closed a 3-year old issue. Have I really been trying to write a #RustLang GUI off-and-on for 3 years now? It feels amazing that I started with a rewrite at the beginning of October and I already feel further along than any of my previous iterations. https://github.com/khonsulabs/gooey/issues/23

Linus on Rust in the Linux kernel (December 2023)
https://www.youtube.com/watch?t=5m36s&v=OvuEYtkOH88
Discussions: https://discu.eu/q/https://www.youtube.com/watch?t=5m36s&v=OvuEYtkOH88
Wrote a reverse polish expression evaluator in #rustlang 🙂 .
This year I've been really enjoying #AdventOfCode solution blogs by
@geekyaubergine : https://zoeaubert.me/tags/advent-of-code/ : #Rust #Rustlang
@robb : https://rknight.me/blog/tags/adventofcode/ : #PHP
@lewis : https://lewisdale.dev/post/tag/advent-of-code-2023/ : #Typescript
Eric Burden : https://www.ericburden.work/categories/advent-of-code-2023/ : #Kotlin
@neilnjae : https://work.njae.me.uk/tag/advent-of-code/ : #Haskell
Who else is writing great explanations of their solutions? Help me find new people.
(I write #Python solutions at https://hamatti.org/adventofcode/2023)
I've brought back support for animated sprites in Kludgine and #Gooey, and wired everything up to the work-in-progress TileMap widget. https://youtu.be/tfLWHtFuWCo #Rust #RustLang
A few days ago somebody poked me about monster repos causing pathologically long run times for `git-warp-time`. A lot of fiddling and a couple releases later v0.7.0 is now about 300× faster. Not 300 percent, 300 times faster!
There is probably one more order of magnitude left on the table with some careful memory caching and threading, but over two orders of magnitude faster is a good start.
#AdventOfCode day 9 https://github.com/Balise42/AoC2023/blob/main/src/day09.rs nothing much to say today!
@kDot I don’t know if this was intended, but I assume age is a big part of the mess that Java is.
But I also think #java took OOP too seriously with all the factories and other patterns.
A better designed language is obviously #rustlang which took all the best from all the languages. The code style is consistent, and reading different code based on rust, is familiar to a rust developer
torrents merger for qBittorrent
https://github.com/tatref/qbittorrent-merger/tree/master
Discussions: https://discu.eu/q/https://github.com/tatref/qbittorrent-merger/tree/master
Created another Rust package for Arch Linux! 🐧
🦀 **cargo-docs-rs**: Imitate the documentation build that docs.rs would do.
⭐ GitHub: https://github.com/dtolnay/cargo-docs-rs

Lucka 9 - Game state
Årets julkalender från Agical är en spelmakarstuga där vi skriver ett shoot'em'up-spel i programmeringsspråket Rust och spelramverket Macroquad. Idag fortsätter vi med lucka 9. I denna lucka blir det lite faktorisering genom att vi lägger till ett så kallat "game state" som gör att vi kan pausa spelet och få en startmeny.
https://macroquad-introduktion.agical.se/ch8-game-state.html
#rust #RustLang #gamedev #game #programmerinf #Adventskalender #macroquad #spel #spelutveckling

I just completed "Mirage Maintenance" - Day 9 - Advent of Code 2023 #AdventOfCode https://adventofcode.com/2023/day/9
That was easy enough that I started writing an "optimised" version in #julialang from the get go. The difficulty is all over the place this year! ( Probably #rustlang and #uiua versions later...)
Given a Datastructure like this:
pub struct Thread {
// contains all messages of a thread
pub messages: Vec<Message>,
// contains the messages as a tree structure
pub root: &Message
}
pub struct Message {
pub children: Vec<Message>
}
I know I need to add lifetime annotations. But is it possible to model a similiar data structure w/o using Rec<RefCell<Message>>? It feels like cheating.
I made some progress 👐
🐱 a rough character design, using #b3d
🐁 other visual changes
🐾 made sure multiplayer is still working
🦈 the genre may be a #roguelike, let's see!
#bevyengine #rustlang #gamedev #screenshotsaturday #indiegame

I've finally found motivation to add some experimental minimal CSS colour support to the #html2text #RustLang crate.
Next step is to see if I can update aoc-cli to make use of this. 🙂

I already loved the rust compiler and the tooling around it, but after a few days of doing #adventofcode in #rust , I'm even more impressed by how good they have become.
Giving #HelixEditor a try as well.
Fumbling with the keybinds, but I wish #vim was this snappy (and required so little config).
Using D to glue together C++ and Rust
https://www.kdab.com/mixing-c-and-rust-for-fun-and-profit-part-1/
Discussions: https://discu.eu/q/https://www.kdab.com/mixing-c-and-rust-for-fun-and-profit-part-1/
`for await` and the battle of buffered streams
https://tmandry.gitlab.io/blog/posts/for-await-buffered-streams/
Discussions: https://discu.eu/q/https://tmandry.gitlab.io/blog/posts/for-await-buffered-streams/
released pict-rs 0.4.6 today.
https://git.asonix.dog/asonix/pict-rs/releases/tag/v0.4.6
big change is a new internal endpoint for preparing for the 0.5.0 upgrade
Announcing Rust 1.74.1 | Rust Blog
https://blog.rust-lang.org/2023/12/07/Rust-1.74.1.html
Discussions: https://discu.eu/q/https://blog.rust-lang.org/2023/12/07/Rust-1.74.1.html
A project of mine, cargo-spdx, got a mention from @ferrous in their response to the RFI on open source software security!
They make the point that leaving security-relevant tooling to be done by solo maintainers is bad, and there should be investment in community and commercial tools. Strong agreement from me!
cargo-spdx: https://github.com/alilleybrinker/cargo-spdx
Ferrous' comments: https://www.regulations.gov/comment/ONCD-2023-0002-0065
This thing will (probably) blow up 🚀
mfio - Framework for #Async I/O Systems:
https://github.com/memflow/mfio
"mfio is a one-stop shop for custom async I/O systems. It allows you to go wild, beyond typical OS APIs.[...]"
- Async
- Automatic batching (vectoring)
- Fragmentation
- Partial success
- Lack of color (full sync support)
- I/O directly to the stack
- Using without standard library
It is so deeply weird to me that this group would write and submit a public document defending C++ to an RFC that includes as a core priority supporting the move away from memory unsafe languages, and then wouldn't sign their names.
All but one other response to the RFC, 105 total, is a named organization, a named individual or individuals, or has no name field filled out and minimal content.
Theirs is the only semi-professional submission which is explicitly "anonymous"
@bobulous You might be able to squeeze some additional performance:
- use #[inline] on small methods that are executed often (in parsers on methods like "next_token")
https://nnethercote.github.io/perf-book/inlining.html
- use `lto = fat` in your Cargo.toml (⚠️ increases build times)
https://nnethercote.github.io/perf-book/build-configuration.html#link-time-optimization
There is more - have a look at this excellent book by @nnethercote
#AdventOfCode Day 8 - part 2 was A LOT of luck, as in "mayyyyybe the input works that way" and it was definitely a shot in the dark, with a side of "a harder version would be day 15, not day 8" - https://github.com/Balise42/AoC2023/blob/main/src/day08.rs
Back in the late 90s I discovered #python and a few weeks later I had a job writing Python ("Can I use Python?" "Is the code readable?" "Yes"). I saw people post how they wished they could use it for their job.
Now I see people post that they wish they could write Rust professionally. I am over a year in. It did take me a few years of on and off learning as obtaining Rust proficiency can take a little while.
The Rust jobs are out there, but you may have to make them
Phew, had me worried for a minute. I'm writing a simple XML 1.0 parser in #Rust just for practice, and on feeding it a 4.4MB XML file it took 56.5s to read it. I've done nothing to optimise it yet, but even so that sounded dire.
Then I remembered to use "release" mode, and the time dropped to 3.9s. Whatever the compiler is doing behind the scenes, I'll take that 14x speed boost, thank you.
Day 10 and 11 of #100DaysOfRust
I'm getting deeper and deeper into the #Rust programming language and learning different ways to implement functions and for what reason. Oh, if I didn't get far in the course yesterday.
I also thought about developing with a #Vim clone on #RustLang, this is #Helix. I also found out about libraries that I might use in the future 🦀
Announcing mfio - Completion I/O for Everyone
Discussions: https://discu.eu/q/https://youtu.be/EBAC1KcjR28
They don’t name themselves. It’s unclear if this is an official ISO C++ response.
Their response tries to muddy what safety means, argues a strawman about Rust having vulnerabilities too, suggests “profiles” for C++ should fix everything anyway, hints thah C++ critics are actually just talking about old C++ (in the same breath they argue that C++ is great because it’s always stable so old code sticks around forever), and that really you should give C++ more money.
lol, a group of unnamed “C++ senior members with decades [of] experience in ISO C++” filed a response to the federal RFI on open source software security and it is ridiculous.
I'm live!
I'm a bit late, spent way too much time on my makeup...
Anyways, we'll be continuing work on the ECS and hopefully finishing this wretched world off >:3
Well... uhhh finishing the world structure hehe :3
https://twitch.tv/ciubix8513
#rust #rustlang #twitch #stream #goinglive
![Release page for cargo-semver-checks v0.26. Release reads:
Four new lints related to items being removed from the public API by making them #[doc(hidden)]. All contributed by @u9g:
- struct_now_doc_hidden
- enum_now_doc_hidden
- function_now_doc_hidden
- trait_now_doc_hidden
All these are semver-major changes, as described in this post: https://predr.ag/blog/checking-semver-for-doc-hidden-items/
Plus, an update to our library API to allow suppressing cargo-semver-checks logging output, to make it more pleasant for other tools to plug in cargo-semver-checks functionality as a library. Contributed by @markhaehnel.
Semver-checking with this release requires Rust 1.71+.](https://assets.toot.cafe/cache/media_attachments/files/111/545/936/037/150/925/small/8599c822d40e8813.png)
You can take this a step further and write a script that automatically extracts all of this panic location metadata, in your reverse engineering tool of choice. I wrote a quick Binary Ninja script that goes and extracts all panic location metadata, finds the locations in the code where they are referenced, and then annotates each location with a tag that displays the extracted source file information. Here are the tags generated by my script, run on a piece of Rust malware targeting macOS systems, RustBucket.
(I like having the scream emoji everywhere 😱)

Note that this location information is only embedded into Rust binaries if the developer uses the default panic behaviour, which unwinds the stack, cleans up memory, and collects information to show in the panic message and in backtraces. You can read more about the details of the default panic implementation in the Rust standard library in the Rust Compiler Dev book.
Developers can trivially strip the location information by just putting panic = 'abort' when specifying the build profile in their Cargo.toml build configuration file; this will cause the program to immediately abort on panic instead, without taking any further actions. Developers can also provide their own custom panic handlers - you can learn more about this in my previous post about the panic handlers used by the Rust code in the Windows kernel, here: https://infosec.exchange/@cxiao/110500609127711155
Of course, a lot of Rust malware out there doesn't even bother taking the more basic step of stripping symbols, much less this panic information... 😉
Compare the above snippet of source code with the decompiler's output, at one of the locations where this particular core::panic::Location
struct is referenced. We can see the following arguments all being passed into the function sub_18001ee90
, which is the entry point to the panic handling logic (notice how the branch where that function is called is also noreturn
).
1) The fixed error message for the unreachable!()
macro (internal error: entered unreachable code
)
2) The length of that error message string (0x28 characters)
3) The address of that core::panic::Location
struct.
[...]
} else {
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
sub_18001ee90("internal error: entered unreachable code", 0x28, &panic_location_"library\std\src\sys\windows\mod.rs")
noreturn
}
uint64_t n_6 = n * 2
if (n_6 u>= 0xffffffff) {
n_6 = 0xffffffff
}
n_2 = n_6
[...]
The information passed in the arguments is used to construct the message that the program emits when it panics, which in this case will look something like the following:
thread 'main' panicked at 'internal error: entered unreachable code', library\std\src\sys\windows\mod.rs:252:17
We can also see several other features which appear in the original source code at this location:
1) The check of the GetLastError()
result against the ERROR_INSUFFICIENT_BUFFER
error code.
2) The saturating multiplication of the variable n
.
Because the Rust standard library is open-source, we can actually go read the source code at the place that this core::panic::Location
data points to. The Rust compiler and standard library live in the same Git repository (rust-lang/rust
) and are released together; the last piece of information we need to find the source code here is the Git commit ID of the Rust compiler / standard library version that was used to create this binary.
This is something we can find by examining some of the other strings in this binary, which contain paths like this, which have the rustc
commit ID embedded inside them:
/rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225\\library\\alloc\\src\\vec\\mod.rs
We can now look up the exact location in the source code: rust-lang/rust
commit 8ede3aae
, File library\std\src\sys\windows\mod.rs
, Line 252 (0xfc), Column 17 (0x11):
fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> crate::io::Result<T> {
[...]
if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
n = n.saturating_mul(2).min(c::DWORD::MAX as usize);
} else if k > n {
n = k;
} else if k == n {
// It is impossible to reach this point.
// On success, k is the returned string length excluding the null.
// On failure, k is the required buffer length including the null.
// Therefore k never equals n.
unreachable!(); // ⬅️ This is the location from our binary!
} else {
[...]
This is indeed a place where the code can panic! The unreachable!()
macro is used to mark locations in the code that should never be reached, in cases where reachability cannot be automatically determined by the compiler. The documentation for unreachable!()
says:
This will always
panic!
becauseunreachable!
is just a shorthand forpanic!
with a fixed, specific message.
Now that we know the layout of core::panic::Location
in our binary, let's define a new type in Binary Ninja which we can apply to the binary. My type definition for this binary is as follows:
struct core::panic::Location
{
struct RustStringSlice file
{
char* address;
int64_t length;
};
uint32_t line;
uint32_t col;
};
The screenshot shows this new type definition applied to the sequence of data, in a nice readable form which shows the line number and column number at a glance.

The type that contains this location information is core::panic::Location
(documentation here) which has the following definition. It consists of a string slice reference (&str
), and two unsigned 32-bit integers (u32
). The string slice reference &str
represents a view of a string, and is made up of two components: a pointer, and a length.
pub struct core::panic::Location<'a> {
file: &'a str,
line: u32,
col: u32,
}
Using Binary Ninja, let's look inside a Rust binary at a place where one of the source file path strings is referenced. This is actually a core::panic::Location
struct, embedded inside the binary.
We can see the following pieces of data, and we can match them against the fields in core::panic::Location
:
1) A pointer with the value 0x18003adb0
, which is the address where the source file path string resides. This is the pointer component of the string slice file
.
2) A sequence of bytes with the value 22 00 00 00 00 00 00 00
, which is the little-endian 64-bit integer value 0x22
. This is the length component of the string slice file
. Note how the length of the path string library\std\src\sys\windows\mod.rs
is 34 (0x22) bytes (when encoded with UTF-8, which is always the encoding used by &str
).
3) A sequence of bytes with the value fc 00 00 00
, which is the little-endian 32-bit integer value 0xfc
. This is the unsigned 32-bit integer line
.
4) A sequence of bytes with the value 11 00 00 00
, which is the little-endian 32-bit integer value 0x11
. This is the unsigned 32-bit integer col
.
⚠️ Caution: In this case, the order of the fields in the compiled binary matched against the definition of core::panic::Location
. However, you cannot rely on this always being the case; the Rust compiler is free to reorder these fields however it wants. Therefore, you must do the work of examining the data in your particular binary, and deducing from that what the layout of core::panic::Location
in your binary is!
For more details on what guarantees the compiler makes (or more importantly, doesn't make) about type layouts, see this section in the Type Layout chapter in The Rust Reference.

🦀 🧵 Rust reversing thread: Let's use panic metadata embedded inside Rust binaries to help us reverse engineer!
If you've ever looked inside the strings of a Rust binary, you may have noticed that many of these strings are paths to Rust source files (.rs
extension). These are used when printing diagnostic messages when the program panics, such as the following message:
thread 'main' panicked at 'oh no!', src\main.rs:314:5
The above message includes both a source file path src\main.rs
, as well as the exact line and column in the source code where the panic occurred. All of this information is embedded in Rust binaries by default, and is recoverable statically!
Examining these can be useful in separating user from library code, as well as in understanding functionality. This is especially nice because Rust's standard library and the majority of third-party Rust libraries are open-source, so you can use the panic strings to find the relevant location in the source code, and use that to aid in reversing.
Postgres Language Server: implementing the Parser
https://supabase.com/blog/postgres-language-server-implementing-parser

On inheritance and why it's good Rust doesn't have it
https://www.thecodedmessage.com/posts/oop-3-inheritance/
Discussions: https://discu.eu/q/https://www.thecodedmessage.com/posts/oop-3-inheritance/
I thought I might try blogging some kind of Rust tutorial alongside learning it myself. So anyway here's the first of a series if you wanna follow along. Just a simple Hello World! https://josh.is-cool.dev/2023-12-7-nature-keeps-evolving-rustaceans/
Lucka 8 - Poängsystem
Nu är det dags att öppna lucka 8 av Agicals julkalender med spelmakarstuga. Igår la vi till så att spelaren kan skjuta ner de elaka fyrkanterna. Idag lägger vi till poängräkning. Hörde vi ”Score!“?
https://macroquad-introduktion.agical.se/ch7-points-system.html
#rust #RustLang #gamedev #game #programmering #Adventskalender #macroquad #spel #spelutveckling


The display of features in rustdoc has been fixed once again.

The @LWN articles on this years #Linux #kernel maintainers summit are now freely available:
https://lwn.net/Articles/951847/
Topics:
* Trust in and maintenance of #filesystems.
* Committing to #Rust / #Rustlang for kernel code
* Reducing kernel-maintainer burnout
* A discussion on kernel-maintainer pain points
Side note: if you wonder who the #LinuxKernel developers in below picture are, checkout this page:

Dump C++ and in Rust you can trust, Five Eyes agencies urge
https://www.theregister.com/2023/12/07/memory_correction_five_eyes/?td=rt-3a
Discussions: https://discu.eu/q/https://www.theregister.com/2023/12/07/memory_correction_five_eyes/?td=rt-3a
winnow, my parser combinator library, now includes a nom migration guide: https://docs.rs/winnow/latest/winnow/_topic/nom/index.html
I love this! This is such a good description of how we (often subconsciously) handle many of the trade-offs for design decisions in #rustlang. I'm really excited to see this written down!
What beliefs do you think are fundamental to Rust?
Read Niko's blog post here: https://smallcultfollowing.com/babysteps/blog/2023/12/07/rust-design-axioms/

💥 New Changelog interview!
This week we’re joined by @drewdevault, talking about the Hare programming language 🐇
We discuss Hare (of course), why he’s so passionate about all things open source, the state of the language, fostering a culture that values stability, and oddly enough — what it takes to make a peanut butter and jelly sandwich 🥪
#foss #oss #opensource #hare #harelang #rust #rustlang #zig #ziglang #sourcehut #github
We hope you enjoy it! 🎧 https://changelog.fm/569
@Exilsarahl hello, i am from the church of #kicad Please be knowenth that this kind of shit never happens around here in our sacred halls.
(but the codebase is really ugly and should be rewritten in #rustlang
I also started publishing #bevyengine Game Jam 4 devlogs!
I don't know how much I'll actually finish during the jam, but my overall goal is to use this week as a spike towards getting something I feel comfortable publishing on steam.
https://www.youtube.com/watch?v=vmTGN_0Crns&list=PLWtPciJ1UMuDEeb0hREZ2HY0D7R_E1C6f&index=1
There's a whole bunch of #adventofcode goodness in this playlist.
From should you even participate? to solutions to each day and even refactoring and discussion of various tools to benchmark with.
https://www.youtube.com/playlist?list=PLWtPciJ1UMuD3_8Pb-EqrFhkYpastR2cn
Getting Started with Axum by @shuttle
I've finished #AdventOfCode 2023 day 6 in #Rust. https://codeberg.org/Firedrake/adventofcode2023/src/branch/main/06 #RustLang
@reginagrogan #RustLang is probably a more accurate hashtag 🙂.
Add support for `gen fn`, https://github.com/rust-lang/rust/pull/118457.
Experimental new `gen fn` has landed in Rust (nightly).