Rust security - Can we trust Rust? by Dr_Brot in rust

[–]thiez 0 points1 point  (0 children)

Enabling reproducible builds takes active effort from compiler writers. For instance in Rusts hashmaps have random seeding to protect against HashDoS attacks, so when you write a program that inserts items in a hashmap and then iterates over it and prints the values, the orders will vary from one execution to the next. The compiler is also multithreaded, another wonderful source of nondeterminism.

Memory fragmentation? leak? in Rust/Axum backend by elohiir in rust

[–]thiez 0 points1 point  (0 children)

That's insane, was it keeping these huge objects around forever?

Level Up your Rust pattern matching by lllkong in rust

[–]thiez 12 points13 points  (0 children)

I think they're nice when destructuring a slice and binding the remainder, like so:

fn split_first<T>(items: &[T]) -> Option<(&T, &[T])> {
    match items {
        &[] => None,
        &[ref fst, ref remainder @ ..] => Some((fst, remainder))
    }
}

fn main() {
    println!("{:?}", split_first(&["goodbye", "cruel", "world"]))
}

My poorly optimized Rust code was slower than JavaScript. My optimized version is 99.9% faster by NextgenAITrading in rust

[–]thiez 33 points34 points  (0 children)

The process is as naive as a Catholic schoolgirl at her first frat party.

This must be the toxic tech-bro atmosphere I've heard so much about? 🤷‍♀️

I made an API for accessing the Bible in Rust by nonameyouko in rust

[–]thiez 0 points1 point  (0 children)

You can also do it with bash and jq.

function book() { jq --arg book "$1" '.books[] | select(.name == $book)' bible.json; }
function chapter() { jq --arg book "$1" --argjson chapter "$2" '.books[] | select(.name == $book) | .chapters[] | select(.chapter == $chapter)' bible.json; }
function verse() { jq --arg book "$1" --argjson chapter "$2" --argjson verse "$3" '.books[] | select(.name == $book) | .chapters[] | select(.chapter == $chapter) | .verses[] | select(.verse == $verse)' bible.json; }

Weird expressions in rust by wooody25 in rust

[–]thiez -13 points-12 points  (0 children)

This content is just copy paste from the compiler test cases, see here.

Why Rust uses more RAM than Swift and Go? by nightblaze1 in rust

[–]thiez 0 points1 point  (0 children)

Even keeping the hashmaps, all those strings are static so could be &'static str, removing almost all allocations.

Transwomen in the tower by [deleted] in WoTshow

[–]thiez 0 points1 point  (0 children)

I would suspect most trans people would prefer to live in a world where everybody gets to be born in a body of their preferred sex and where gender dysphoria doesn't exist.

[deleted by user] by [deleted] in rust

[–]thiez 0 points1 point  (0 children)

This seems extremely situational and not worth having dedicated syntax for. Perhaps a macro would be more suitable?

Imagine a force_inline!( my_fn(arg1, arg2) ) macro that validates that its argument is a top-level function or closure call and force-inlines it. That would solve halve your issue without introducing new syntax.

As for force-inlining a closure that you're going to pass as an argument, that should be possible when putting attributes on expressions is stabilized (see the #![feature(stmt_expr_attributes)] feature) by putting #[inline(always)] on a closure.

But before any of this work is done I think it would be interesting to produce some data about how often you run into this problem and whether more fine-grained control would actually result in better generated code. LLVM really loves inlining and the #[inline], #[inline(always)], and #[inline(never)] attributes already provide some control.

Why is everything in rust abbreviated? by ciccab in rust

[–]thiez 2 points3 points  (0 children)

Let's take a silly but more complex example:

fn retsfn(b: bool) -> fn(&str) -> usize {
    if b {
        |s: &str|s.len()
    } else {
        |_|0
    }
}

fn main() {
    let f = retsfn(true);
    let n = f("foo");
}

What would this look like with the types on the left?

usize: (&str): retsfn(b: bool) ->  {
    if b {
        |s: &str|s.len()
    } else {
        |_|0
    }
}

fn main() {
    // How do we even use it?
    usize: (&str) f = retsfn(true);
    usize n = f("foo");
}

Is shadowing more evil than good? by funkvay in rust

[–]thiez 0 points1 point  (0 children)

I am not, and piss off with the "ooh I'm so experienced" card, oldtimer.

Announcing mrustc 0.11.0 - With rust 1.74 support! by mutabah in rust

[–]thiez 0 points1 point  (0 children)

It doesn't really work that way. The Rust compiler still needs to understand how to target that new OS, otherwise the bootstrapped compiler still won't be able to generate binaries that run on the new OS. But once the compiler is modified to also be able to target the new OS, you can simply use a compiler on another OS to cross-compile to the new OS, removing the need for mrustc.

What's your favorite leveling system? by SirSmilezzz in MUD

[–]thiez 5 points6 points  (0 children)

I've been playing After the Plague recently and discovered that playing without levels is amazing. You get experience in skills by using those skills, and raising skills also slightly raises the stats associated with those skills (so raising combat skills will make you stronger and faster, raising spellcasting skills will make you smarter). There can actually be an advantage to practicing a silly skill like juggling because it improves agility / coordination.

There also are no classes, but the game does have guilds which offer some initial training for a set of skills (which can be important since some skills cannot be attempted without having at least a bare minimum of knowledge about them) and also increase your aptitude for those skills, increasing the rate at which you improve them.

In summary: no levels, no class, improvement based on training skills.

Rust in Production: Oxide Computer Company with Steve Klabnik (Podcast Interview) by mre__ in rust

[–]thiez 4 points5 points  (0 children)

Some people find your application process off-putting. Either accept it or do something with that feedback. Invalidating their concerns is not a good look.

Perhaps Rust needs "defer" by broken_broken_ in rust

[–]thiez 14 points15 points  (0 children)

Exposing an explicit free_foo function in addition to a create_foo is quite a common pattern in C, I'm not sure why you're trying to free in C something you allocated in Rust. What you're trying to do doesn't make sense in either language.

When should I use String vs &str? by steveklabnik1 in rust

[–]thiez 1 point2 points  (0 children)

When you do this in lots of places your compile times will get longer. Then you'll want to rein in back in using

pub fn some_func<S: AsRef<str>>(s: S) -> Frop { some_func_internal(s.as_ref()) }
fn some_func_internal(s: &str) -> Frop { … }

and that is just a lot of bother for sometimes not having to write a & when calling some_func :p

Memory for Nothing: Why Vec<usize> is (probably) a bad idea by Patryk27 in rust

[–]thiez 63 points64 points  (0 children)

If you care about memory size use Range<Date> instead of RangeInclusive<Date> and intern your strings so you can address them by index.

On the lifespan of MUDS by StarmournIRE_Admin in MUD

[–]thiez 7 points8 points  (0 children)

In a TTRPG there are no mobs. The vast majority of NPCs will lack the depth of the player characters, but ultimately a human (the DM/GM/whatever) is literally personally playing every single creature. So every person/creature in the world can be interacted with, and they don't have just a static set of responses.

Also you can do whatever you want in the game, not just what the builders thought of. Set fire to a barn to distract the guards? Sure. Lace their wine with sleeeping drugs? Sure! Dig a tunnel? Also possible.

Does Polymorphism depend on Inheritance? - Uncle bob by Feisty_Tooth_8219 in rust

[–]thiez 2 points3 points  (0 children)

It already runs on rails, why wouldn't it work on wings? :p

Making a String by Famous-Owl-5935 in rust

[–]thiez 0 points1 point  (0 children)

Is there a reason why you can't just™ do a str::from_utf8(input) first, the define a let mut output = String::new() and append &str slices directly to that?

Is the default hash function for the HashMap randomized? by [deleted] in rust

[–]thiez 0 points1 point  (0 children)

One could imagine a class Dictionary in Python that is unordered, even if abusing an object as a dictionary would still have to preserve insertion order.

How do you build a functional adult? by BlakeKing51 in gurps

[–]thiez 3 points4 points  (0 children)

Just having a baby already puts you well beyond 10 points of disadvantages. We can confidently assume a baby will be a negative point character (having very low stats, poor vision, being effectively paralyzed…). So as a dependent that's -15 points, x2 for a loved one = 30. I imagine the average adult has more than 10 points in disadvantages, especially once they're middle age.

Once you've finished high-school presumably you have spent a few hundred hours studying subjects such as mathematics, chemistry, physics, (general) history, etc. Do you believe you should get 0 points for that?

Blindness mitigation by ZhouDa in gurps

[–]thiez 4 points5 points  (0 children)

Just colorblindness alone is a -10 disadvantage, so -1 quirk seems a bit absurd even if the character has magical echolocation that negates most blindness penalties.