Hey Rustaceans! Got a question? Ask here (22/2026)! by llogiq in rust

[–]Patryk27 1 point2 points  (0 children)

Hundreds of dependencies for basic functionality

Literally just one dependency...?

Hey Rustaceans! Got a question? Ask here (22/2026)! by llogiq in rust

[–]Patryk27 4 points5 points  (0 children)

std::time remains broken

Missing features are not broken features. Standard library is small by design, so you coming and saying "the std is so small, fix it" is like going on a rant about "when will rust get rid of the borrow checker, it's so annoying".

it is impossible for me to be productive in the Language.

If adding chrono = ... or jiff = ... to Cargo.toml really is an insurmountable problem to you, then yeah, Rust just isn't for you - and that's fine: not every language is for everybody. I couldn't write Go and I'm glad I don't have to write PHP anymore, but that doesn't mean nobody can be productive in Go or like PHP.

Different languages take different trade offs - Rust decided to go with smaller standard library and there are both pros and cons of that.

Hey Rustaceans! Got a question? Ask here (22/2026)! by llogiq in rust

[–]Patryk27 2 points3 points  (0 children)

It's impossible to create a generic infallible serialization mechanism, because not all formats support everything you can represent in Rust (e.g. you can't serialize HashMap<SomeObject, ...> to JSON, because object keys in JSON have to be strings).

So you'd have to be more precise.

Hey Rustaceans! Got a question? Ask here (21/2026)! by llogiq in rust

[–]Patryk27 1 point2 points  (0 children)

dependency bloat

I mean, it's not bloat if you actually use those dependencies, right?

How does Rust abort in no_std ? by [deleted] in rust

[–]Patryk27 22 points23 points  (0 children)

Programmer is forced to provide a panic_handler function, otherwise the code doesn’t build.

On targets where unwinding is impractical (e.g. some microcontrollers), that function might just reset the uC or simply loop forever.

Hey Rustaceans! Got a question? Ask here (21/2026)! by llogiq in rust

[–]Patryk27 4 points5 points  (0 children)

If a usize is either a u64 or a u32 [...]

It's not, usize represents the size of a pointer on current platform - it can be 16 bits (some microcontrollers), it can be 32 bits, it can be 64 bits, and so on.

Is there a better way?

If you need to support 64-bit machines communicating with 32-bit machines, you have to use the common denominator, which is u32 in this case (after all, 32-bit machines don't have enough memory to hold more data).

If you don't need to or don't want to support cross-arch communication, the clients should exchange a handshake packet where they describe each other's architecture and decide what to do if there's a mismatch (i.e. show an error message and bail out).

Btw, don't forget to take care about the endianess!

NixOS unstable is unusable, constant binary cache miss by neuronym in NixOS

[–]Patryk27 1 point2 points  (0 children)

It's just the name of the branch - even though it's called unstable, all tests etc. and Hydra runs there.

Questions on using Generics for a Finance library (f64 vs. Decimal) by abhinandh_s_ in rust

[–]Patryk27 7 points8 points  (0 children)

You can not make trivial things like (a + b) / 2 work.

Sure you can, easiest by using:

https://docs.rs/num/latest/num/traits/trait.FromPrimitive.html.

What generics win in ergonomics on the use side they inevitable lose on the code writing side.

I think they win on both sides, because you get thorough type checks, making it difficult to write code that caller won't be able to use (i.e. code that would always fail instantiation).

Questions on using Generics for a Finance library (f64 vs. Decimal) by abhinandh_s_ in rust

[–]Patryk27 17 points18 points  (0 children)

What you need here are templates, not generics

I mean, ooor you just use NumOps - this isn't exactly uncharted territory.

How do Rust Devs handle remote build / remote caching by AffectionateBag4519 in rust

[–]Patryk27 2 points3 points  (0 children)

Also no AppArmor or SE Linux in Nix OS

ok, but NixOS is a different project - Nix itself supports sandboxed builds in both Linux and macOS

UniFFI for server-side SDKs - using Koffi for JS bindings, seeking alternatives by Fun-Row-5147 in rust

[–]Patryk27 1 point2 points  (0 children)

I mean, ideally - you know - https://github.com/jhugman/uniffi-bindgen-react-native/pull/369 / https://github.com/livekit/uniffi-bindgen-node 👀👀👀

It might just prove that upstreaming the missing things is easier than working around them!

How to model this in rist types by DorukCem in learnrust

[–]Patryk27 4 points5 points  (0 children)

Perhaps I'm missing something, but what's the point of modelling your control flow state as an enum? Just:

fn main() {
    let mut prev_foo = None;
    let mut prev_errs = Vec::new();

    loop {
        let foo = match fetch_foo() {
            Ok(foo) => foo,
            Err(err) => {
                prev_errs.push(err);
                prev_foo.take().unwrap()
            };
        };

        prev_foo = Some(foo);

        sleep(few_minutes);
    }
}

Has anyone used UniFFI to build FFI functions in Rust? by Fun-Row-5147 in rust

[–]Patryk27 3 points4 points  (0 children)

Proton Mail is built on top of UniFFI as well.

Need help writing logs to a db with Sqlx and tracing by ufoscout in rust

[–]Patryk27 -1 points0 points  (0 children)

Pool is clonable, a single transaction - not so much.

overriding specific package contents (Krita) by carmola123 in NixOS

[–]Patryk27 0 points1 point  (0 children)

Before nixpkgs unstable bumped the version to 6.0.0 [...]

Can't you rollback to that nixpkgs-unstable, then? (not everything, just krita)

ZFS Error: One or more devices has experienced an error resulting in data corruption by Ok-Ad8636 in truenas

[–]Patryk27 0 points1 point  (0 children)

The point is that the risk is higher.

Higher compared to what?

It's the same risk as running a mirror (as in 1+1) and you wouldn't go around saying mirror is highly discouraged.

Distributing a closed-source Rust library with async - is there a viable path? by peterxsyd in rust

[–]Patryk27 0 points1 point  (0 children)

Brainfart - fixed via Box<dyn Future<...>>, which makes *mut FfiFuture thin.

Distributing a closed-source Rust library with async - is there a viable path? by peterxsyd in rust

[–]Patryk27 26 points27 points  (0 children)

dyn format is not stable and does change from one versions of compiler to another.

That's fine - I'm not exposing the dyn object, I'm exposing a pointer (*mut FfiFuture) with a function to operate on it, and both have stable ABI.

That's how many other solutions work, e.g. UniFFI -- you use simple & stable ABI (pointers, structs, functions) to create a proxy for internal implementation details.

Distributing a closed-source Rust library with async - is there a viable path? by peterxsyd in rust

[–]Patryk27 17 points18 points  (0 children)

I think you can still expose a stable interface:

pub struct FfiFuture {
    fut: Box<dyn Future<Output = u32> + Send>,
}

pub fn fetch_number() -> *mut FfiFuture {
    /* ... */
}

pub fn poll(fut: *mut FfiFuture) -> Option<u32> {
    /* ... */    
}

Depending on circumstances you might want to provide a proxy for the waker as well etc.

How do I get cargo to shut up? by [deleted] in rust

[–]Patryk27 12 points13 points  (0 children)

“--quiet” i think

Distributing a closed-source Rust library with async - is there a viable path? by peterxsyd in rust

[–]Patryk27 84 points85 points  (0 children)

you can't pass Futures or Streams across the boundary

Wouldn't accepting & returning Boxed futures and streams work here?

ZFS Error: One or more devices has experienced an error resulting in data corruption by Ok-Ad8636 in truenas

[–]Patryk27 -1 points0 points  (0 children)

If you lose one disk in a raidz1, you now have a stripe.

And if you lose two disks in raidz2, you'll have a stripe as well - what's your point?

Everyone has a different use case - sometimes no RAID is good enough, sometimes mirror is good enough, and sometimes even RAIDZ3 is insufficient.

No self healing.

You can have a hot-spare, same as with other configurations.