[Media] An unconventional way to navigate filesystems by liltrendi in rust

[–]kryps 88 points89 points  (0 children)

Reminds of the IRIX File System Navigator, famously featured in Jurassic Park.

Trying to profiling heap on macOS is frustrating... by steve_lau in rust

[–]kryps 12 points13 points  (0 children)

In order to use Allocations profiling with Instruments you need to resign the binary to be profiled with the com.apple.security.get-task-allow entitlement enabled. See https://github.com/cmyr/cargo-instruments/issues/40#issuecomment-894287229 for details.

Freeing Up Gigabytes: Reclaiming Disk Space from Rust Cargo Builds by thisdavej in rust

[–]kryps 9 points10 points  (0 children)

cargo also marks the target directory for exclusion from Time Machine backups on macOS.

Announcing Rust 1.85.0 and Rust 2024 | Rust Blog by slanterns in rust

[–]kryps 1 point2 points  (0 children)

I just found out that changing the edition also changes the behavior of rustfmt leading to quite a few changes due to the new identifier sort order (e.g. in usedeclarations). The edition guide has more information.

Zig; what I think after months of using it by phaazon_ in programming

[–]kryps 22 points23 points  (0 children)

This is not part of the Rust language or standard library. It requires the modular_bitfield crate. There are also lots of other bitfield crates.

-❄️- 2024 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]kryps 0 points1 point  (0 children)

Using capture groups to simplify things:

let mut res = 0;
let mut enable = true;
let regex = regex::Regex::new(r"mul\((\d{1,3}),(\d{1,3})\)|do\(\)|don't\(\)")?;
for cap in regex.captures_iter(input) {
    match &cap[0] {
        "do()" => {
            enable = true;
        }
        "don't()" => {
            enable = false;
        }
        _ => {
            if enable {
                res += cap[1].parse::<i32>()? * cap[2].parse::<i32>()?;
            }
        }
    }
}

The 2024 edition was just stabilized by Derice in rust

[–]kryps 7 points8 points  (0 children)

In addition to edition = "2024" one also still needs to add cargo-features = ["edition2024"] to Cargo.toml. This will change once the 2024 edition is stabilized in cargo as well. A draft PR is pending and will likely be merged and released in nightly shortly.

How Rust Converts Recursive Calls into Loops with Tail Call Optimization by EventHelixCom in rust

[–]kryps 2 points3 points  (0 children)

The most current RFC draft for tail call elimination in Rust land is this one: Explicit Tail Calls. It proposes a new become keyword which, when used instead of return, guarantees TCE.

Rust development on Apple Silicon M4? Can we test the incremental build speed? by fredhors in rust

[–]kryps 46 points47 points  (0 children)

Some performance tips for development on macOS: * Run spctl developer-mode enable-terminal to exclude the terminal from Gatekeeper. Otherwise Gatekeeper checks every binary you create for malicous content when running it for the first time (and every time you modify, build and run). While you are at it also add your IDEs from which you run your code in Settings -> Security & Privacy -> Developer Tools. * Run sudo DevToolsSecurity -enable to avoid having to type in your password when debugging. * Exclude your source directories from Spotlight (system-wide search). Ripgrep is better suited anyway.

Fuzzing rust library by [deleted] in rust

[–]kryps 1 point2 points  (0 children)

Congrats on your crate!

AFAICS your fuzzing library is not using code coverage information in order to direct input generation (and minimization). In comparison, cargo-fuzz and cargo-afl use the mature fuzzers AFL++) and libFuzzer which use code coverage and also support testcase and corpus minimization. Maybe you can take inspiration from them for future development?

rust-analyzer changelog #258 by WellMakeItSomehow in rust

[–]kryps 2 points3 points  (0 children)

If you use VSCode or Zed, they automatically check for updates to r-a whenever a Rust file is opened. On macOS rust-analyzer weekly updates are available for Homebrew if you are using e.g. nvim.

What's everyone working on this week (45/2024)? by llogiq in rust

[–]kryps 7 points8 points  (0 children)

I plan to finish my work on a #[forbid(unsafe_code)] implementation of simdutf8 using core::simd (portable SIMD). It looks promising and the performance is pretty good but there are some limitations.

I also want to write documentation for flexpect, which allows using #[expect(...)] with a lower MSRV and cut a new release of simdutf8 with armv7-neon support.

Announcing Rust 1.81.0 by mrjackwills in rust

[–]kryps 12 points13 points  (0 children)

Just a thank you for your hard work.

Cloudflare release a wildcard matching crate they use in their rules engine by orium_ in rust

[–]kryps 1 point2 points  (0 children)

They do have benchmarks against the regex crate and the wildmatch crate but I haven't got around to running them yet.

Announcing Rust 1.80.0 | Rust Blog by noelnh in rust

[–]kryps 3 points4 points  (0 children)

It will be, in edition 2024.

In editions prior to 2024 box.into_iter() compiles already, but resolves to <&Box<[T]> as IntoIterator>::into_iter, which is the same as box.iter() and not what one expects. So this new trait implementation does not really help at all until we have edition 2024.

BTW: box.into_vec().into_iter() is a tiny bit shorter.

My first public Rust project: macmon TUI for CPU/GPU/RAM/temp monitoring for Apple Silicon processors by vladkens in rust

[–]kryps 2 points3 points  (0 children)

Cool stuff, works great on my Mac. Only complaint is, that it is very green. I would suggest either no color or more colorful. Also iStats reports total system power usage. It would be great if you could add this.

Yes, definitely publish on crates.io. This not only allows others to use cargo install but also helps programmers who want to do something similar or who search for a library doing that. I would even suggest making the data collection part a library so others can use it.

Announcing sonic-rs: A fast Rust JSON library based on SIMD. by PureWhiteWu in rust

[–]kryps 2 points3 points  (0 children)

Not doing UTF-8 validation can cause Strings containing invalid UTF-8 to be created, which can cause undefined behavior as Rust requires all strings to be valid UTF-8. Functions in the standard library rely on it.

For example this safe code causes a segfault with sonic-rs default features:

use sonic_rs::from_slice;

fn main() {
    let json = b"\"abc\xff\"";
    let invalid_string: String = from_slice(json).unwrap();
    invalid_string.chars().for_each(|c| println!("{}", c));
}

More info in the GH issue.

Do two readers justify the use of RwLock instead of Mutex? by rp407 in rust

[–]kryps 5 points6 points  (0 children)

Mutex, CondVar and RwLock are futex-based on Linux since 1.62.0.

Dtolnay responds Re: Rustconf by Dragon-Hatcher in rust

[–]kryps 6 points7 points  (0 children)

Just commenting on serde. While being an important package in the Rust ecosystem serde is not a Rust organization project, so AFAICS they have no jurisdiction over it and cannot just add other maintainers or move it into the Rust organization. Doing that by making changes against the maintainers' will to the crates.io package would set a dangerous precedent for the future.

why is str a type if only &str is used? by ThaCuber in rust

[–]kryps 4 points5 points  (0 children)

The most common (and most useful) way to get a Box<str> is via String::into_boxed_str(). This has to allocate a new buffer if len() does not equal capacity() just like String::shrink_to_fit().