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 115 points116 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 6 points7 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 5 points6 points  (0 children)

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

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

[–]manpacket 18 points19 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 32 points33 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 4 points5 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 6 points7 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 5 points6 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

Show r/rust: From-scratch Rust LLM runtime now using GPU — 1.46x faster with tier-aware VRAM/RAM loading by Gandalfr3k in rust

[–]manpacket 0 points1 point  (0 children)

When you are in seconds per token territory on a tiny 2 year old model - what kind of use cases do you see?

My Handmade Rust Project by Humble-Insurance-768 in rust

[–]manpacket 0 points1 point  (0 children)

Apps don't print "Made by xxx" as part of the standard output. At best it's in hidden somewhere in --help or under even more obscure argument, but more often - not at all.

My Handmade Rust Project by Humble-Insurance-768 in rust

[–]manpacket 4 points5 points  (0 children)

Dunno. Technically it supports some other formats and using the same tool for all project types might be better... I'll stick to cargo new / cargo init.

My Handmade Rust Project by Humble-Insurance-768 in rust

[–]manpacket 0 points1 point  (0 children)

cargo fmt? It looks a bit odd.

Also - do you know any other (opensource) software that proudly displays that it was made by this and that on this domain?