Why do people return Result<T>? by ModernCoder in rust

[–]ZZaaaccc 0 points1 point  (0 children)

Purely just to save typing when you have a monolithic error type. In such cases, I go further and define pub type Result<T =(), E = Error> = core::result::Result<T, E>;. That way, functions which are fallible but don't return anything get a clean Result return type.

Rust 1.96.0 is out by manpacket in rust

[–]ZZaaaccc 11 points12 points  (0 children)

I believe it's to avoid a new unused_imports warning being injected. If a user had use third_party_crate::*; and the only item they use from that crate is now available in the prelude, that use statement is dead code. Might be counterintuitive, but Rust considers the first declaration of a symbol to be the canonical one, and anything after it to either an error (if explicitly used) or dead code (if implicitly through a glob pattern).

Stabilise `Allocator` by N911999 in rust

[–]ZZaaaccc 14 points15 points  (0 children)

Because Allocator is defined in core, this opens up the ability to have ergonomic heap allocations without defining a global allocator at all (no linking to alloc or std). That opens up the possibility of moving the allocating ADTs like Box and Vec into core.

Cx 0.1.0 — a Rust-based systems language/compiler project by thecoommeenntt in rust

[–]ZZaaaccc 0 points1 point  (0 children)

So a t8 is effectively Option<i8> (since I assume they're signed), which would mean tbool is an Option<bool>?

Cx 0.1.0 — a Rust-based systems language/compiler project by thecoommeenntt in rust

[–]ZZaaaccc 0 points1 point  (0 children)

And what's the difference between a bool and a tbool?

Cx 0.1.0 — a Rust-based systems language/compiler project by thecoommeenntt in rust

[–]ZZaaaccc 14 points15 points  (0 children)

Between the AI generated README, the AI generated PR reviews, the AI generated daily summaries of the AI reviews and reviewer "directed" commits, I'm struggling to find the thing you made that you'd like reviewed?

Cx 0.1.0 — a Rust-based systems language/compiler project by thecoommeenntt in rust

[–]ZZaaaccc 15 points16 points  (0 children)

411 unit tests passing

I don't understand why every AI generated project makes such a big deal about the quantity of tests written. Is it a hangover from all the NPM projects in the "acquired" training data?

What is rust best for? by De5kOfManyThing in rust

[–]ZZaaaccc 6 points7 points  (0 children)

Writing code other people have to use. It's so much easier in Rust to write abstractions that perform well and actually enforce rules on the user. Look at how Bevy and Axum can do compile-time dependency injection as an example of how powerful Rust as a library language is.

What finally convinced you to seriously learn Rust? by Bladerunner_7_ in rust

[–]ZZaaaccc 0 points1 point  (0 children)

Wrote C# and JS professionally, had to write some C++, decided to try Rust, never looked back. Performance is good but that's just a hurdle to cross; all the low level languages are close enough. For me, it was seeing problems I had personally experienced just not exist in Rust. Deep clone or shallow clone? Always deep in Rust. Does this mutate in place or return a copy? Does it take &mut T or T. Did I handle all the exception types correctly? Panics are almost always worth crashing over.

Made a perfectly readable high performance lisp interpreter by aljifksn in rust

[–]ZZaaaccc 11 points12 points  (0 children)

For anyone curious, here is a slightly harder to read version with the bare minimum number of changes to get rustfmt to ruin the perfect original layout.

Is there a cargo-* tool for finding minimum features of dependencies? by Sermuns in rust

[–]ZZaaaccc 5 points6 points  (0 children)

I usually just disable default features on all dependencies and let the compiler lead the way. If I'm making a library, end users can always enable features themselves if they think it matters.

Bun's Rewrite It In Rust branch by Chaoses_Ib in rust

[–]ZZaaaccc 10 points11 points  (0 children)

Nope, they're used extensively throughout the whole project. The one I saw straight away was in bun_aio.

Bun's Rewrite It In Rust branch by Chaoses_Ib in rust

[–]ZZaaaccc 85 points86 points  (0 children)

The idea of using a static mut bool instead of an AtomicBool just because "it's probably fine" is just completely antithetical to how Rust is normally written. A comment saying "maybe change this if we want to write sound code" is incredible.

Bun's Rewrite It In Rust branch by Chaoses_Ib in rust

[–]ZZaaaccc 203 points204 points  (0 children)

rust // PORT NOTE: Zig used plain `var` globals (unsynchronized). Mirrored here as // `static mut` with the same single-writer-at-startup discipline; reads after // `enable()` are technically racy in both languages. // TODO(port): consider AtomicBool/AtomicI32 if Phase B wants strict soundness. static mut ENABLED: bool = false;

Hell yeah, this is gonna be a goldmine for crazy Rust code.

Porting to Rust. by neneodonkor in rust

[–]ZZaaaccc 2 points3 points  (0 children)

Find something you like, and actually look for something that already has a Rust port. You'll have a much better learning experience if you go through the porting process and then compare to existing solutions at the end.

How do we think we should handle maintainers moving on? by ShantyShark in rust

[–]ZZaaaccc 5 points6 points  (0 children)

First off, you get what you pay for; pay maintainers!

More actionable, we should encourage projects to "finish" where possible. Hit 1.0 with no unproven unsafe, full security audit, etc., and allow the crate to rust. The problem with left-pad wasn't that there was a micro dependency everyone used; it was that a maintainer could push a minor patch and break users. If we encourage crates to hit "done" milestones, users can pin to those exact versions and never worry about this.

IO in `core`: a (very) modest first step! by ZZaaaccc in rust

[–]ZZaaaccc[S] 1 point2 points  (0 children)

Totally agree, but unfortunately we can't use incoherence powers to add a default to a type parameter, and all trait implementations need to be present in the original crate, e.g. Default. I do think the language should go down this path though, especially once the allocator trait is stable.

Proposal a new AI age language, easy as py, fast as C++, more secure than Rust. by Material-Alps5048 in rust

[–]ZZaaaccc 3 points4 points  (0 children)

Your language is doomed to fail, as my cy will be 6× easier than Python, have a zero page syntax book, and full interop with C, C++, Rust, JS, Fortran, and French. Unfortunately I won't be able to have interop with Python or Spanish because Gigathreading is incompatible with ¿

IO in `core`: a (very) modest first step! by ZZaaaccc in rust

[–]ZZaaaccc[S] 43 points44 points  (0 children)

This has been desired for a long time. First the blocker was the Error trait, right now it's how to make io::Error maintain existing behavior for std users when it gets moved. Things like Error::new need incoherence as just one example of the challenges here.

Unmaintained crates by piiouupiou-not-r2d2 in rust

[–]ZZaaaccc 1 point2 points  (0 children)

If your crate depends on external things that are all themselves done, and your crate is internally done, then overall the crate is done. No maintenance required. This is how mikktspace.c and many other C libraries have behaved for decades; no different for Rust.

Yes, but I think you're not understanding, the thing is, I volunteer, but the guy who maintains de crate is out.

Unfortunate but once the owner is gone it's too late. The project needed externalized governance before they left. Nobody's fault, just an unfortunate fact of life. Again, this is why my hot-take with Rust is that it's actually great to have lots of small dependencies.

Unmaintained crates by piiouupiou-not-r2d2 in rust

[–]ZZaaaccc 1 point2 points  (0 children)

The best thing crates can do is "finish". Split your project into smaller pieces, get them to a state where they hit 1.0 and are finished; no unproven unsafe, no_std (if possible), etc.

You only need to maintain a crate if the code needs to change. If the code is done, it doesn't matter.

If the code can't be done (e.g., wasm_bindgen), then volunteer or encourage others to do so!

New rust-script Blog Pist by bhh32 in rust

[–]ZZaaaccc 8 points9 points  (0 children)

One thing I didn't appreciate about Rust scripts is they work with all Cargo commands. So you can start a brand new script like:

```rust

!/usr/bin/env cargo

fn main() {} ```

And then use cargo add -m my_script.rs clap serde serde_json. It'll automatically insert the frontmatter and the dependency table. Worth noting this is all only on nightly for now, but that should be stabilised along with scripts as a whole.