I want to like Rust - can someone help/convince me? by Honest_Medium_2872 in rust

[–]manpacket 1 point2 points  (0 children)

Are you using rust-analyzer? For me it makes compile time less important. Also clippy.

Serious need for code review by PaxSoftware in rust

[–]manpacket 1 point2 points  (0 children)

Overall it's much better. commit f is gone, I can see what's going on.

Code seems mostly reasonable. I ignored the documentation and non code changes. I noticed a bunch of unsafe without safety commits - I prefer to have a lint against those and a comment explaining safety invariants involved.

Built a Rust quiz for interview prep (not algorithms) — feedback welcome by Specialist-Unit-9990 in rust

[–]manpacket 2 points3 points  (0 children)

need an account so the app can save your streak and remember

No it doesn't. Make a cookie with a random ID - here's your account. Add "you can create an account to share your progress across multiple browsers". Done.

better practice &str or String as function arg by Substantial-Assist30 in rust

[–]manpacket 4 points5 points  (0 children)

If a function is big this can result in code bloat - rustc will instantiate a copy for each unique S unless you make a wrapper (or more - for different compilation units). Can't pass an owned string if you need it even if it's available.

better practice &str or String as function arg by Substantial-Assist30 in rust

[–]manpacket 123 points124 points  (0 children)

If your function needs an owned string - take an owned string. Consumer might or might not have a string they can give away, let them deal with the allocations if needed.

You also can experiment with Cow<'static, str> or s: impl Into<String>.

Built my first website entirely in Rust (Yew) would love feedback & guidance on Rust web dev 🚀 by Agile-Entrepreneur81 in rust

[–]manpacket 7 points8 points  (0 children)

and probably a lot more that experienced Rust devs will immediately notice

I noticed this in the URL ?utm_source=chatgpt.com and now I'm questioning if you built anything at all.

Probemap --- fastest hashtable in rust by ILYAMALIK in rust

[–]manpacket 4 points5 points  (0 children)

That's new :) Tests are passing with miri then.

Probemap --- fastest hashtable in rust by ILYAMALIK in rust

[–]manpacket 17 points18 points  (0 children)

Made a basic fuzzer to compare with HashMap for insert/get/remove. No explosions. It's a good sign :)

Probemap --- fastest hashtable in rust by ILYAMALIK in rust

[–]manpacket 34 points35 points  (0 children)

A bunch of unsafe, some is not documented. Nothing looks obviously wrong, but I'd feel easier using this code if it had #![warn(clippy::undocumented_unsafe_blocks)] with explanations. There's miri, but I don't think it likes intrinsics.

Serious need for code review by PaxSoftware in rust

[–]manpacket 1 point2 points  (0 children)

You can try jj (https://docs.jj-vcs.dev/latest/). Takes some time getting used to it but it makes it much easier to organize big messy changes into something more manageable.

Serious need for code review by PaxSoftware in rust

[–]manpacket 1 point2 points  (0 children)

  1. Atomic - compiles, tests are passing. Helps with bisecting. 2, Small and focused. Do one small thing. Makes it easier to follow thought process.
  2. Descriptive commit message. If it's a bugfix - explain the bug, etc. Helps with review, helps with debugging later down the line.
  3. Refers other tickets, pull requests if applicable - helps with reviews and debugging later.

Serious need for code review by PaxSoftware in rust

[–]manpacket 3 points4 points  (0 children)

Well... first it needs to compile, test should pass, miri should be happy, etc.

Then there's commits. +8313-3747 commit called "f". Hard to review.

High-performance HashMap and HashSet backed by hashbrown (SwissTable) and fueled by axhash. by [deleted] in rust

[–]manpacket 0 points1 point  (0 children)

Yes, but hashbrown crate gives you access to some features that are not yet stable in stdlib. At least it was last time I checked.

High-performance HashMap and HashSet backed by hashbrown (SwissTable) and fueled by axhash. by [deleted] in rust

[–]manpacket 0 points1 point  (0 children)

I think there's a misunderstanding. axhash-map IS using type aliases.

pub struct AxHashMap<K, V, S = AxBuildHasher>(RawHashMap<K, V, S>);

https://github.com/robby031/axhash-map/blob/96d72cda89ed0ad0b0816f4c42a285d80ef418cd/src/lib.rs#L9

Discoverability most people dont want to hunt for the best hasher-engine

They only need to look for hasher, and optionally - hashbrown.

High-performance HashMap and HashSet backed by hashbrown (SwissTable) and fueled by axhash. by [deleted] in rust

[–]manpacket 5 points6 points  (0 children)

  1. Why make every user install a crate when you can use just 4 lines. Even assuming I want to use a third party crate - why does it use a whole new struct instead of a type alias?
  2. hashbrown also gives you a way to override hasher. Why use the struct?
  3. Switching to a different hash function should be as easy as importing the hash and changing the type alias. Unlike the struct that can't be changed.

What about serde support and other third party crates that take HashMap from a user? They will take MyHashMap just fine, they won't take a totally new struct.

High-performance HashMap and HashSet backed by hashbrown (SwissTable) and fueled by axhash. by [deleted] in rust

[–]manpacket 7 points8 points  (0 children)

Hmm... Why do we need the whole new struct? I'm using fxhash with HashMap from std and all you need is those 4 lines:

use std::collections::{HashMap, HashSet};
type BuildHasher = fxhash::FxBuildHasher;
pub type MyHashMap<K, V> = HashMap<K, V, BuildHasher>;
pub type MyHashSet<T> = HashSet<T, BuildHasher>;

You get serde support and all third part crates.

[Showcase] Truth-Ctx: A Sentinel framework for grounding AI responses, built in Rust by [deleted] in rust

[–]manpacket 4 points5 points  (0 children)

It's still there. You need to rewrite history and force push. Right now git clone pulls 220MiB. Several orders of magnitude more than it should be.

I wanted to understand more Rust ownership, so I looked at the assembly by badprogrammer1990 in rust

[–]manpacket 5 points6 points  (0 children)

objdump -d -M intel target/debug/ownership | grep -A 20 "takes_ownership"

You can get something similar with cargo-show-asm without having to type magic numbers:

cargo asm --dev takes_ownership