Profile for hikari

Header for hikari
Avatar for hikari
Display name
Kanbaru 🌟 (one hikari of too many)
Username
@hikari@noyu.me
Role
admin

About hikari

Bio

from another world; anime girls on the internet who are terrible at playing guitar and slightly less bad at programming; EN/SV/DE/日本語

Stats

Joined
Posts
18736
Followed by
1560
Following
200

Recent posts

rust question. a common pattern in code i’ve written is:

assert!(foo % bar == 0);
let count = foo / bar;

is there a standard way to do that as a single operation?

one of the things i really like about rust is how it helps you avoid errors by combining an assertion of some assumption (e.g. “foo is not None”) with obtaining a value based on that assumption (e.g. getting the value inside the Some()). so in this case, it’d be really nice if i could do something like foo.div_exact(bar).unwrap(). personally i’d put it in the stdlib…

Open thread at this post

Rust pro tip: if you have a C/C++ dependency for your project that you have to compile in your build script, consider making it into its own crate. Then it can be compiled in parallel to your Rust code, and it won't be recompiled unnecessarily if you need to change something else that has a build script. You can use Cargo “workspaces” to keep it in the same repo as your main crate.

Open thread at this post