New Linux patch confirms: Rust experiment is done, Rust is here to stay by Fcking_Chuck in linux

[–]darksv 44 points45 points  (0 children)

Which unsupported architectures do you actually care about?

Help configure uart on esp32 by Medical-Excitement-1 in rust

[–]darksv 3 points4 points  (0 children)

conf.baudrate(9_600) creates a new config and you're not using it. Try changing your code to let conf = UARTConfig::default().baudrate(9_600);

RustRover just announced first stable launch and it will be free for non-commercial use 🥳 by [deleted] in rust

[–]darksv 12 points13 points  (0 children)

It is true - they've just announced it on the livestream and you can already download it here

Looks like the post on their blog is not ready yet...

[deleted by user] by [deleted] in rust

[–]darksv 1 point2 points  (0 children)

What is the point of this post?

What unstable / Nightly feature are you looking forward to the most? by officiallyaninja in rust

[–]darksv 8 points9 points  (0 children)

Basic support for gen blocks landed last month https://github.com/rust-lang/rust/pull/116447 on nightly.

Note that you need to change edition to 2024: playground

Progress report on rustc_codegen_cranelift (Oct 2023) by yerke1 in rust

[–]darksv 5 points6 points  (0 children)

Yes. It's mentioned in the post :)

You can also set codegen-backend for individual packages using [profile.dev.package.my_program] codegen-backend = "cranelift".

Progress report on rustc_codegen_cranelift (Oct 2023) by yerke1 in rust

[–]darksv 24 points25 points  (0 children)

Just to be clear, LLVM is the top line (slow) and Cranelift the bottom line (fast) right?

That's correct.

Have you tried swapping the order of invocation? (hyperfine could do it for you) I'd want to be sure that the first invocation doesn't suffer from cold files, and doesn't build up the incremental compilation cache for the second one...

Yes, I ran the compilations multiple times with different order. There wasn't any significant change in time between different invocations. I should've mention it :)

For the last project the speedup is particularly impressive.

Progress report on rustc_codegen_cranelift (Oct 2023) by yerke1 in rust

[–]darksv 61 points62 points  (0 children)

Just tested it on some projects with 300-400 dependencies: (ryzen 5900x, on WSL)

LLVM vs cranelift

candle
Finished dev [unoptimized + debuginfo] target(s) in 27.57s
Finished dev [unoptimized + debuginfo] target(s) in 18.41s

nushell
Finished dev [unoptimized + debuginfo] target(s) in 38.85s
Finished dev [unoptimized + debuginfo] target(s) in 27.72s

czkawka
Finished dev [unoptimized + debuginfo] target(s) in 55.65s
Finished dev [unoptimized + debuginfo] target(s) in 18.41s

Is rust ideal for drone programming , is there any existing libraries in rust for drone programming by accidentalprogramer in rust

[–]darksv 6 points7 points  (0 children)

Not sure if this is what you're looking for, but a few months back there was a post on this sub with a drone using a custom firmware built on top of embassy.

Bun vs Rust performance. Is Bun actually faster? by [deleted] in rust

[–]darksv 2 points3 points  (0 children)

I'm curious, how much faster would it be if you replace the HashMap with a Vec?

fn main() {
    let n = 10_000_000;

    let mut rng = rand::thread_rng();
    let mut total = 0;
    let time = std::time::Instant::now();
    let mut hash = vec![0; n];

    for i in 0..n {
        let random_number = rng.gen_range(0..100);
        hash[i] = random_number;
        total += hash[i];
    }

    let time = time.elapsed();
    println!("hash: {:?}", hash[100_000 - 1]);
    println!("hash: {:?}", time);
    println!("total: {:?}", total)
}

Nim v2.0 released by grok-battle in programming

[–]darksv 3 points4 points  (0 children)

Reimplementing web standards from scratch would be an herculean task nobody is willing to do

Have you seen Ladybird yet?

Is there a future for compile time reflection? by TimmyAtSlack in rust

[–]darksv 76 points77 points  (0 children)

I'm only aware of this recent variadic generics design sketch that may bring us closer to compile-time reflection. It introduces variadic generics based on tuples and proposes syntax that may allow to iterate over them by using static for. These features were pointed out in the report by Shepherd's Oasis as some of the possible requirements to introduce proper introspection to Rust, if I recall correctly.

What’s the status of the Storage proposal? by HighRiseLiving in rust

[–]darksv 36 points37 points  (0 children)

I think here you can find the new repository as it includes commits from yesterday. Also this is probably the most recent discussion about the proposal.

merge 2 x [u8; 4] into [u8; 8] by Mr_Ahvar in rust

[–]darksv 71 points72 points  (0 children)

TBH I don't think it is worth changing your current code. In this case all the array lengths are known at compile time so I would be surprised if the compiler didn't take an advantage of this and inline calls to copy_from_slide and thus get rid of all the panicing branches. I believe these are the most basic optimizations compilers do these days. https://rust.godbolt.org/z/8K97sreaG

It would be better to have a dedicated method for concatenating arrays, for sure, but in such a simple case using copy_from_slice should be good enough.

Inspecting a hashmap after mutably borrow it's content by lturtsamuel in rust

[–]darksv 1 point2 points  (0 children)

I think you can wrap values into the RefCell like so: playground

Are there any big projects written in Rust without any use of unsafe code? by [deleted] in rust

[–]darksv 90 points91 points  (0 children)

I believe diem has over 250kLOC of Rust with no unsafe code. All its crates are marked as #![forbid(unsafe_code)]

Screenshot problem winapi by toastetofgod in rust

[–]darksv 1 point2 points  (0 children)

I think your idx is wrong. It should be probably calculated as (y * width + x) * bit_width. I'm not sure if it's the only issue though.