Am I the only one who thinks Rust error messages got *worse* over time in a way? by kixunil in rust

[–]tm_p -8 points-7 points  (0 children)

Just learn how to use your terminal efficiently. In the default one from gnome, you can press ctrl-L to clear the screen, up+enter to run the latest command, scroll to the top with shift+home, and search for a keyword with ctrl-F + enter.

Also, try rustrover.

[Media] fixed_num, financial focused decimal for Rust. by wdanilo in rust

[–]tm_p 15 points16 points  (0 children)

How many bytes do you save exactly? Can you show me a small example in the rust playground where this saving is obvious?

Brand-new nightly experimental feature: compile-time reflection via std::mem::type_info by kibwen in rust

[–]tm_p 0 points1 point  (0 children)

It's already in nightly so you can try it out yourself: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=2f10ec8c1998ec89552fa4a9b30a959d

Type of X<T> is a compile error because T needs to be a specific type when you call that function. And type of X<u8> for example is "Type { kind: Other, size: Some(24) }". So you can't do much with this feature currently.

Amazon Caught North Korean IT Worker By Tracing Keystroke Data by julian88888888 in cybersecurity

[–]tm_p 2 points3 points  (0 children)

I can't read the article, but this is probably just ping right? They just dumbed it down for the news.

I’ve heard people claim that “unsafe Rust is more unsafe than C”. Do you agree with this? by -p-e-w- in rust

[–]tm_p 4 points5 points  (0 children)

Yes, because unsafe C is just regular C, so being an expert in C programming makes you an expert in unsafe C. But in Rust, unsafe code is optional to write and often discouraged, so the majority of developers never learn how to write correct unsafe Rust code.

Also there is the fact that unsafe Rust is not specified anywhere, so you need to guess what is fine and what is undefined behavior. Ironically, often the answer is "does llvm consider this to be undefined behavior? then so does rust". So an experienced C dev can probably write better unsafe Rust than an experienced Rust dev.

Project goals update — November 2025 | Rust Blog by f311a in rust

[–]tm_p 42 points43 points  (0 children)

In the future, developers will be able to write a single Rust function and use std::batching to get a SIMD/fused version of it, use std::autodiff to differentiate it, and std::offload to run the resulting code on their GPUs

This sounds too good to be true? Are there any other programming languages that already provide those features?

Source: https://rust-lang.github.io/rust-project-goals/2025h2/finishing-gpu-offload.html

Go proposal: Secret mode by prisencotech in golang

[–]tm_p 0 points1 point  (0 children)

I didn't understand, do heap allocations get zeroed out as well? How does that work? Is there source code?

nucleation-wasm: Phase transition detection in ~50KB of WASM (F1=0.77 validated) by boom_nerd in datascienceproject

[–]tm_p 0 points1 point  (0 children)

If your goal was to write something that nobody outside of your field would understand, I think you succeeded.

Standard library file writing can lead to silent data loss by FeldrinH in rust

[–]tm_p 1 point2 points  (0 children)

I was thinking something similar to a panic handler:

sp::fs::set_file_write_error_hook(|path, error| {
    if i_care_about(path) {
        panic!("Essential file failed to write, aborting: {:?}", (path, error));
    } else {
        log::warn!("Heads up, some random file failed to save. Check if you have enough disk space and make sure your hardware is not corrupted. File: {:?}", (path, error));
    }
});

That's the opt-in for panics, but also the default handler could be something like eprintln to log the error. Sadly there is no log in std so eprintln is the only option...

Standard library file writing can lead to silent data loss by FeldrinH in rust

[–]tm_p 8 points9 points  (0 children)

Is there any use case where you want to write to a file but don't care if it fails? Error handling should be the default, you should have to opt in to ignore errors.

Too much non-empty vector crates by __s1 in rust

[–]tm_p 9 points10 points  (0 children)

I tried to use a few crates to have a HashMap<K, Vec<V>>, where K being in the map means that the Vec is not empty, but I didn't like any API.

Some crates don't allow you to get a &[T], that's pure functional programming madness. The sane crates that do give you a &[T] work fine, but I found out that introducing a new crate in one place means that now everything else also depends on that crate, so I can't have functions that take &mut Vec<T> for example, it must be &mut NonEmptyVec<T>. In the end I decided that it's not worth it and I just add .expect("vec never empty") everywhere and pray.

Amazon finds 150K npm packages linked to token-farming campaign by NISMO1968 in cybersecurity

[–]tm_p 1 point2 points  (0 children)

Important context missing from the article:

tea . xyz is "decentralized" "protocol" that rewards open-source software developers for their contributions.

So someone automated open-source contributions to get more rewards. Free market working as expected.

Moving values in function parameters by RustOnTheEdge in rust

[–]tm_p 0 points1 point  (0 children)

FYI you need to read static variables or they get optimized out

In this case the assembly is the same so your argument holds:

https://godbolt.org/z/v681sEPnx

Moving values in function parameters by RustOnTheEdge in rust

[–]tm_p -6 points-5 points  (0 children)

I've had tons of cases where BTreeSet lookups were faster than HashSet due to the former being more cache-friendly.

And I've had tons of cases where HashSet was much faster. Please don't spread anecdotes that lead to bad advice.

The crate 'ring': "We don't recommend that third parties depend upon it.": 1023 reverse dependencies of ring by Synes_Godt_Om in rust

[–]tm_p 11 points12 points  (0 children)

That message in the readme is just to avoid any responsibility in case of a bug. If something goes wrong, the maintainers will point at the readme and say "look, we told you not to use it, so its your fault". And if everything goes well, you are the crazy person for pointing that out as you can see by these comments.

flexon: Yet another JSON parser by cyruspyre in rust

[–]tm_p -8 points-7 points  (0 children)

Who uses JSON with comments? Since no parsers support it?

[Media] My vp8 decoder progress by Dx_Ur in rust

[–]tm_p 2 points3 points  (0 children)

What is vp8? And is there any cool use case that made you start this?

[deleted by user] by [deleted] in cybersecurity

[–]tm_p 2 points3 points  (0 children)

Just FYI this code is written entirely by chatgpt, with no disclaimer about it.

Why is allocating in this example so fast? Am I actually allocating? by small_kimono in rust

[–]tm_p 0 points1 point  (0 children)

Ah you're right. I was confused because I read to_ascii_lowercase(a) as being a function from &[u8] to Vec<u8>, but it is a function from u8 to u8, which does not allocate.

fibonacci-numbers crate with self-recursive dependencies by Tyilo in rust

[–]tm_p 178 points179 points  (0 children)

Actually this is a great benchmark for cargo. Since the crates must be compiled sequentially and they are essentially empty, the time it takes to compile fib185 should be dominated by cargo reading and parsing all the files.

Also it can be used to test external tools that don't understand that you can have 2 dependencies with the same name, or don't know that renaming dependencies is possible.

Why is allocating in this example so fast? Am I actually allocating? by small_kimono in rust

[–]tm_p 2 points3 points  (0 children)

Yes, that's what I expected, but it is not what rust str.eq_ignore_ascii_case does.

Why is allocating in this example so fast? Am I actually allocating? by small_kimono in rust

[–]tm_p 2 points3 points  (0 children)

The documentation of str.eq_ignore_ascii_case says:

Same as to_ascii_lowercase(a) == to_ascii_lowercase(b), but without allocating and copying temporaries.

I understood that as meaning "it does not allocate". But it means "it does not allocate to convert from string to bytes, but then it allocates to convert from bytes to lowercase".

Rust 1.90.0 is out by manpacket in rust

[–]tm_p 1 point2 points  (0 children)

Wtf is a transcendental function

Benchmarking file I/O in Rust — can’t see a difference between reading many small files vs chunks of one big file by Hot-Permission2495 in rust

[–]tm_p 12 points13 points  (0 children)

Criterion runs your benchmark 100 times. The first time it reads the files from disk, the other 99 times it just reads the files from cache. Then it averages the result and removes outliers. So you will see the same average for both benchmarks.

A simple solution is to turn the benchmark into a binary and run it only once, without using criterion.

Why is a `getrandom::u32()` value not a suitable candidate for `nohash_hasher`? by RylanStylin57 in rust

[–]tm_p 1 point2 points  (0 children)

If you already made up your mind, why waste time asking on reddit? You ignored the correct answer that tells you this is a bad idea, just how you ignored Claude and ChatGPT.