Rust

Partial workaround for missing `decls` param to `@Struct`

Partial workaround for missing `decls` param to `@Struct`

I just had plain c.sdl* functions and I decided that I want to strip them to sdl.* Gnerally it is just about trying to find a way to create decls for comptime generated struct (As a probably a lot of people tried: example1, example2). And I found one way! In zig you can do following: // It is...

Ziggit Blog Ziggit Blog · Rust ·
0
[Roc] How Our Rust-to-Zig Rewrite is Going

[Roc] How Our Rust-to-Zig Rewrite is Going

Richard’s style of writing is less similar to mine than Andrew’s or Mitchell’s: he reads as a bit more generous and takes time to say things that I might just leave to a reader to notice. Excellent move, to move up this blog post ahead of the 0.1.0 announcement, given current events 😉 Anyway,...

Ziggit Blog Ziggit Blog · Rust ·
0
How to deal with `undefined` buffers in ReleaseSafe mode

How to deal with `undefined` buffers in ReleaseSafe mode

I’d really like to use ReleaseSafe builds by default, but I keep finding them unreasonably slow. A common source of slowdowns is var large_buf: [N]u8 = undefined. If you have something like that in the hot path, it has meaningful impact. I’ve seen some other thread that memset is not actually as...

Ziggit Blog Ziggit Blog · Rust ·
0
std.Io.{Reader,Writer} and positional reads/writes

std.Io.{Reader,Writer} and positional reads/writes

I currently try to implement an fs for which I require positional reads/writes. For testing purposes I would like to have the implementation only take *std.Io.Reader and *std.Io.Writer instead of an *std.Io.File, but I noticed that the interfaces don’t expose positional reads/writes, not even se...

Ziggit Blog Ziggit Blog · Rust ·
0
Embed binary data at compile time

Embed binary data at compile time

Hey 🙂 this is my first Post and also my first attempts at metaprogramming. For my Project im working on, i needed some icons and found them in the form of SVGs. Because i want this project to be small and minimal, and because i need the icons the whole time the Program is running, i want to em...

Ziggit Blog Ziggit Blog · Rust ·
0
R

This Week in Rust 660

Hello and welcome to another issue of This Week in Rust! Rust is a programming language empowering everyone to build reliable and efficient software. This is a weekly summary of its progress and community. Want something mentioned? Tag us at @thisweekinrust.bsky.social on Bluesky or @ThisWeekinRu...

This Week in Rust This Week in Rust · Rust ·
0
A question on a switch of a comptime known value

A question on a switch of a comptime known value

this is a function from my vector library, it sets the X axis of a vector (the first element in a SIMD vector) to the provided value. question is: how would the compiler handles this given that dimensions is a comptime_int and so it is comptime known, would it make a copy of the function for eac...

Ziggit Blog Ziggit Blog · Rust ·
0
Zero Sugar Added Jam: the Zig gamejam!

Zero Sugar Added Jam: the Zig gamejam!

Zero Sugar Added A zig-only game jam, with a unique gimmick for each jam, focused on limiting you in fun ways! A couple of months ago, me, @evaleek and @Sietse2202 decided we wanted to host a zig gamejam to show our love for the language, game development, and the community! As said above, the...

Ziggit Blog Ziggit Blog · Rust ·
0
Segmentation fault on `shrinkToLen`

Segmentation fault on `shrinkToLen`

Hello, i am having an issue where i am getting seg fault on a seemingly random spot of the code. using a step debugger, the path to crash is -> array_list.zig 1142:26 -> allocator.zig 360:18 -> allocator.zig 448:5 -> compiler_rt.zig 684:14 Segmentation fault at address 0x7f0d40580000 lib/std/m...

Ziggit Blog Ziggit Blog · Rust ·
0
Using build.zig as a library

Using build.zig as a library

I am writing an application that needs, at runtime, to download resources from the internet and pre-process them. But I want to skip the work on subsequent launches. This seems exactly the problem solved by build.zig. Is there a nice way to re-use that in my application? The brute-force would be...

Ziggit Blog Ziggit Blog · Rust ·
0
Runtime Array creation

Runtime Array creation

Hi, recently ive been having to create runtime arrays where i have some data to iterate over and append it to an array, and although i have a way that works (and even think is the proper/accepted way) One of my usecases: create an array of the cli arguments. Solution: pub fn argsToArray(gpa: st...

Ziggit Blog Ziggit Blog · Rust ·
0
Static Maps

Static Maps

I need to create a map with amino acids as keys and values that represent their mass (f32). Amino acids, the building blocks of proteins, are represented by a single capital letter–there are just 20 of them. I created the working solution below that uses string keys, but is there something simila...

Ziggit Blog Ziggit Blog · Rust ·
0
`deinit` `.empty` MultiArrayList

`deinit` `.empty` MultiArrayList

Hello, I was wondering how MultiArrayList.deinit interacts with a MultiArrayList obtained with .empty? I see empty is defined as follows: pub const empty: Self = .{ .bytes = undefined, .len = 0, .capacity = 0, }; … and deinit as follows: /// <SNIP> fn allocatedBytes(self: Self) []a...

Ziggit Blog Ziggit Blog · Rust ·
0
Simd operation for combining multiple u64 values

Simd operation for combining multiple u64 values

I have (almost) never done anything with simd operations. Time to play around with it. When I want to bitwise combine the following (chess) struct would that be a good candidate for simd (instead of ‘manually’ combine all fields with another Threats struct)? Operations like and, or, xor. Or so...

Ziggit Blog Ziggit Blog · Rust ·
0
Playing with zig and assembly

Playing with zig and assembly

assembly-zig I spent some time learning assembly and took the opportunity to do so while also trying to interact with Zig code from assembly and vice-versa. I learned a lot about calling conventions, X86 assembly, Zig – at the time 0.16.0 wasn’t tagged yet so I also got to experiment with the...

Ziggit Blog Ziggit Blog · Assembly · Rust ·
0
Ignore dependency build.zig.zon `paths` in build script

Ignore dependency build.zig.zon `paths` in build script

I’m trying to include licenses / readmes from my dependencies in my project, as well as bundle dependency source code with my releases to comply with copyleft licenses (Im statically compiling to a lone executable). However, some of my dependencies exclude their readme/license from their build.zi...

Ziggit Blog Ziggit Blog · Rust ·
0
Using freetype c in zig

Using freetype c in zig

const std = @import("std"); const Io = std.Io; const pow = std.math.pow; const gl = @cImport({ @cDefine("GLAD_GL_IMPLEMENTATION", ""); @cInclude("glad/gl.h"); @cDefine("GLFW_INCLUDE_NONE", ""); @cInclude("GLFW/glfw3.h"); @cInclude("GL/gl.h"); }); const ftp = @cImport({ @cI...

Ziggit Blog Ziggit Blog · Rust ·
0
Zig Asset Bundler

Zig Asset Bundler

Zig Asset Bundler Compress and embed directories into your Zig executable. This is a first initial release, I plan to use it in Zine because the Zine executable needs to contain all the assets that are part of the template website you get when you run zine init. As the readme says, I would l...

Ziggit Blog Ziggit Blog · Rust ·
0
R

This Week in Rust 659

Hello and welcome to another issue of This Week in Rust! Rust is a programming language empowering everyone to build reliable and efficient software. This is a weekly summary of its progress and community. Want something mentioned? Tag us at @thisweekinrust.bsky.social on Bluesky or @ThisWeekinRu...

This Week in Rust This Week in Rust · Rust ·
0
R

This Week in Rust 658

Hello and welcome to another issue of This Week in Rust! Rust is a programming language empowering everyone to build reliable and efficient software. This is a weekly summary of its progress and community. Want something mentioned? Tag us at @thisweekinrust.bsky.social on Bluesky or @ThisWeekinRu...

This Week in Rust This Week in Rust · Rust ·
0
R

This Week in Rust 657

Hello and welcome to another issue of This Week in Rust! Rust is a programming language empowering everyone to build reliable and efficient software. This is a weekly summary of its progress and community. Want something mentioned? Tag us at @thisweekinrust.bsky.social on Bluesky or @ThisWeekinRu...

This Week in Rust This Week in Rust · Rust ·
0
The most trusted code on Earth is being rewritten in Rust

The most trusted code on Earth is being rewritten in Rust

Junie is the #1 coding agent on SWE-Rebench and it'll save you a bunch of tokens - https://jb.gg/Fireship-Junie-GA Use code: FIRESHIP20 to to get 20 free AI credits SQLite, the world's most trusted code, just got rewritten in Rust and it actually works. It's called Turso and it ships some cool...

Fireship Fireship · Rust ·
0
R

This Week in Rust 656

Hello and welcome to another issue of This Week in Rust! Rust is a programming language empowering everyone to build reliable and efficient software. This is a weekly summary of its progress and community. Want something mentioned? Tag us at @thisweekinrust.bsky.social on Bluesky or @ThisWeekinRu...

This Week in Rust This Week in Rust · Rust ·
0
R

This Week in Rust 655

Hello and welcome to another issue of This Week in Rust! Rust is a programming language empowering everyone to build reliable and efficient software. This is a weekly summary of its progress and community. Want something mentioned? Tag us at @thisweekinrust.bsky.social on Bluesky or @ThisWeekinRu...

This Week in Rust This Week in Rust · Rust ·
0
Extending Ruzzy with LibAFL

Extending Ruzzy with LibAFL

"We added LibAFL support to Ruzzy, our coverage-guided fuzzer for pure Ruby code and Ruby C extensions. This gives Ruby developers and security researchers access to a more advanced and actively maintained fuzzing engine without changing how they write their fuzzing harnesses."

Trail of Bits Blog Trail of Bits Blog · Rust · DevOps · Backend ·
0
Making our own spectrogram

Making our own spectrogram

A couple months ago I made a loudness meter and went way too in-depth into how humans have measured loudness over time. Today we’re looking at a spectrogram visualization I made, which is a lot mor...

fasterthanli.me fasterthanli.me · Rust ·
0
crates.io phishing attempt

crates.io phishing attempt

Earlier this week, an npm supply chain attack. It’s turn for crates.io, the main public repository for Rust crates (packages). The phishing e-mail looks like this: And it leads to a GitHub login pa...

fasterthanli.me fasterthanli.me · Rust ·
0
The virtue of unsynn

The virtue of unsynn

Addressing the rumors There have been rumors going around, in the Reddit thread for facet, my take on reflection in Rust, which happened a bit too early, but here we are, cat’s out of the bag, let’...

fasterthanli.me fasterthanli.me · Rust ·
0
The promise of Rust

The promise of Rust

The part that makes Rust scary is the part that makes it unique. And it’s also what I miss in other programming languages — let me explain! Rust syntax starts simple. This function prints a number:...

fasterthanli.me fasterthanli.me · Rust ·
0
The case for sans-io

The case for sans-io

The most popular option to decompress ZIP files from the Rust programming language is a crate simply named zip — At the time of this writing, it has 48 million downloads. It’s fully-featured, suppo...

fasterthanli.me fasterthanli.me · Rust ·
0
Catching up with async Rust

Catching up with async Rust

In December 2023, a minor miracle happened: async fn in traits shipped. As of Rust 1.39, we already had free-standing async functions: pub async fn read_hosts() -> eyre::Result<Vec<u8>> { // et...

fasterthanli.me fasterthanli.me · Rust ·
0
R

Generators with UnpinCell

In July, I described a way to make pinning more ergonomic by integrating it more fully into the language. Last week, I develoepd that idea further with the notion of UnpinCell: a wrapper type that lets a user take an &pin mut UnpinCell<T> and produce an &mut T, similar to how other cells let a us...

Without Boats Without Boats · Rust ·
0
R

UnpinCell

A variation on my previous design for pinned places has occurred to me that would be more consistent with Rust’s existing feature set.

Without Boats Without Boats · Rust ·
0
ktls now under the rustls org

ktls now under the rustls org

What’s a ktls I started work on ktls and ktls-sys, a pair of crates exposing Kernel TLS offload to Rust, about two years ago. kTLS lets the kernel (and, in turn, any network interface that supports...

fasterthanli.me fasterthanli.me · Rust ·
0
R

Pinned places

In the previous post, I described the goal of Rust’s Pin type and the history of how it came to exist. When we were initially developing this API in 2018, one of our explicit goals was the limit the number of changes we would make to Rust, because we wanted to ship a “minimum viable product” of a...

Without Boats Without Boats · Rust ·
0
R

Pin

The Pin type (and the concept of pinning in general) is a foundational building block on which the rest of the the Rust async ecosystem stands. Unfortunately, it has also been one of the least accessible and most misunderstood elements of async Rust. This post is meant to explain what Pin achieve...

Without Boats Without Boats · Rust ·
0
R

Ownership

This post is meant as an explainer about how substructural type theory can be applied in programming language design. Terms like “substructural type theory” tend to scare and confuse programmers who don’t write Haskell on the weekends, so one thing programming language designers should do when th...

Without Boats Without Boats · Rust ·
0
R

Asynchronous clean-up

One problem with the design of async Rust is what do about async clean-up code. Consider that you have a type representing some object or operation (like an async IO handle) and it runs clean up code when you are done using it, but that clean up code itself is also non-blocking and could yield co...

Without Boats Without Boats · Rust ·
0
R

FuturesUnordered and the order of futures

In my previous post, I wrote about the distinction between “multi-task” and “intra-task” concurrency in async Rust. I want to open this post by considering a common pattern that users encounter, and how they might implement a solution using each technique.

Without Boats Without Boats · Rust ·
0
R

poll_progress

Last week, Tyler Mandry published an interesting post about a problem that the Rust project calls “Barbara battles buffered streams.” Tyler does a good job explaining the issue, but briefly the problem is that the buffering adapters from the futures library (Buffered and BufferUnordered) do not i...

Without Boats Without Boats · Rust ·
0
R

Three problems of pinning

When we developed the Pin API, our vision was that “ordinary users” - that is, users using the “high-level” registers of Rust, would never have to interact with it. We intended that only users implementing Futures by hand, in the “low-level” register, would have to deal with that additional compl...

Without Boats Without Boats · Rust ·
0
R

Coroutines, asynchronous and iterative

I wanted to follow up my previous post with a small note elaborating on the use of coroutines for asynchrony and iteration from a more abstract perspective. I realized the point I made about AsyncIterator being the product of Iterator and Future makes a bit more sense if you also consider the “ba...

Without Boats Without Boats · Rust ·
0
R

poll_next

In my previous post, I said that the single best thing the Rust project could do for users is stabilize AsyncIterator. I specifically meant the interface that already exists in the standard library, which uses a method called poll_next. Ideally this would have happened years ago, but the second b...

Without Boats Without Boats · Rust ·
0
R

A four year plan for async Rust

Four years ago today, the Rust async/await feature was released in version 1.39.0. The announcement post says that “this work has been a long time in development – the key ideas for zero-cost futures, for example, were first proposed by Aaron Turon and Alex Crichton in 2016”. It’s now been longer...

Without Boats Without Boats · Rust ·
0
R

Thread-per-core

I want to address a controversy that has gripped the Rust community for the past year or so: the choice by the prominent async “runtimes” to default to multi-threaded executors that perform work-stealing to balance work dynamically among their many tasks. Some Rust users are unhappy with this dec...

Without Boats Without Boats · Rust ·
0
R

Follow up to "Changing the rules of Rust"

In my previous post, I described the idea of using an edition mechanism to introduce a new auto trait. I wrote that the compiler would need to create an “unbreakable firewall” to prevent using !Leak types from the new edition with code from the old edition that assumes values of all types can be...

Without Boats Without Boats · Rust ·
0
R

Changing the rules of Rust

In Rust, there are certain API decisions about what is and isn’t sound that impact all Rust code. That is, a decision was made to allow or not allow types which have certain safety requirements, and now all users are committed to that decision. They can’t just use a different API with different r...

Without Boats Without Boats · Rust ·
0
R

A governance system, if you can keep it

One of the most famous anecdotes that forms the basis of the United States’ political self-identity is the story of an interaction between Benjamin Franklin and Elizabeth Willing Powel after the Constitutional Convention of 1787, which established the United States’ present form of government. Po...

Without Boats Without Boats · Rust ·
0
R

The Scoped Task trilemma

This is the first post in a series of posts about concurrency in Rust, and the different APIs that can exist to support it. Unlike my recent series on control-flow effects, this series isn’t driving toward any particular vision of what I think the Rust project should do. Instead, I am just trying...

Without Boats Without Boats · Rust ·
0
R

Generators

One of the main emphases of my recent posts has been that I believe shipping generators would solve a lot of user problems by making it easy to write imperative iterative code, and especially to make that iterative code interact well with asynchrony and fallibility as well. One thing that frustra...

Without Boats Without Boats · Rust ·
0
R

The AsyncIterator interface

In a previous post, I established the notion of “registers” - code in Rust can be written in different registers, and it’s important to adequately support all registers. I specifically discussed the low-level interface of the AsyncIterator trait, about which there is currently a debate. The inter...

Without Boats Without Boats · Rust ·
0
R

Patterns & Abstractions

This is the second post in an informal series commenting on the design of async Rust in 2023. In my previous post, after a discussion of the “registers” in which control-flow effects could be handled in Rust, I promised to turn my attention to recent proposals around a concept called “keyword gen...

Without Boats Without Boats · Rust ·
0
R

The registers of Rust

It’s been nearly two and half years since I was an active contributor to the Rust project. There are some releases that I’ve been very excited about since then, and I’m heartened by Niko’s recent blog post emphasizing stability and polish over grand new projects. But I’ve also felt a certain appr...

Without Boats Without Boats · Rust ·
0
Loading more…