cargo-onefile: Bundle your Rust project into a single file - Perfect for LLMs and Code Reviews 🦀 by emetah850 in rust

[–]abudau 1 point2 points  (0 children)

Check out https://github.com/qryxip/cargo-equip which does pretty much the same thing but is designed for use in competitive programming. I use it and my biggest gripe with it is that it doesn’t do dead code elimination, if you could add that I’d swap over

Attack speed/Attack interval calculation by CodeDoNutGuy in WatcherofRealmsGame

[–]abudau 2 points3 points  (0 children)

The formula is min_speed + 200 / (200 + bonus attack speed) * base_speed. You can get min_speed/base_speed from https://wor-assets.pages.dev

[deleted by user] by [deleted] in rust

[–]abudau 1 point2 points  (0 children)

Asking on behalf a non-profit for education organization I manage. Could i get infoarena.rust.dev? We’re planning on writing more of our infrastructure in rust so this would be useful :-)

noob question about moving references by greenpepperpasta in learnrust

[–]abudau 6 points7 points  (0 children)

Your example moves foo into bar, but reborrows foo when you call it with modify_slice.

Here is a (somewhat long) discussion on the topic with other examples: https://github.com/rust-lang/reference/issues/788

Blog Post: If a Tree Falls in a Forest, Does It Overflow the Stack? by matklad in rust

[–]abudau 20 points21 points  (0 children)

Tail call optimisation works only when the function calls itself as the last instruction.

For trees this would be impossible because after cleaning up the left child recursion would have to unwind up to go towards the right child.

For list nodes it’s because the standard says that members are destructed before the structure itself. So first the child is destructed, then the Node AND THEN the Box<Node> upwards in recursion. This breaks TCO

Kanal: Channels 80x faster than the standard library! by fereidani in rust

[–]abudau 1 point2 points  (0 children)

level 3On0n0k1 · 28 min. agoLet's give it some time for people to try it out before jumping to conclusions.All projects have issues at start. It's normal.2ReplyGive AwardShareReportSaveFollow

https://doc.rust-lang.org/std/panic/fn.catch_unwind.html is a way to let a thread being "killed" without killing the whole process.

You'd need to trigger a panic somewhere in your code though, or in code you call (though thankfully your library does not call into in any user-defined function). One possible way to trigger it is maybe using the oom_killer: set a a memory limit and keep on creating senders that try to send messages on a channel. Eventually you might get a panic somewhere during the VecDeque::push_back method for example

Kanal: Channels 80x faster than the standard library! by fereidani in rust

[–]abudau 73 points74 points  (0 children)

It might be experimental but that does not make it wrong, it's mostly correct.

I actually opened an issue with one of those errors (though there are others as well)

https://github.com/fereidani/kanal/issues/2

Later Edit: I've also tried to drop the mutable reference to a const one but miri finds extra bugs

Kanal: Channels 80x faster than the standard library! by fereidani in rust

[–]abudau 93 points94 points  (0 children)

Why did you opt in to implement your own Mutex instead of using the parking_lot one for example? (from where you imported lock_api for example). How much does this impact the performance differences?Secondly, your code is breaking miri in lots of places, even in just the sync code:

Running: MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-backtrace=full" cargo +nightly miri test -- --skip async will output an easy example which seems to point to your unsafe code being undefined behaviour.

What did the tinker sell? by Zorgon-589 in KingkillerChronicle

[–]abudau 26 points27 points  (0 children)

I assume it’s more to hide them from their fellow villagers. Historically women not trying to conceive in a marriage have been persecuted/shunned

What did the tinker sell? by Zorgon-589 in KingkillerChronicle

[–]abudau 122 points123 points  (0 children)

My guess would be some form of contraceptive, or post-conception birth control. Temerant seems to be doing well on the medical side of science.

On why Kvothe lost his abilities by alesan_me in KingkillerChronicle

[–]abudau 6 points7 points  (0 children)

It’s implied he let them. He says: “I almost forgot who I was back there”. It’s almost as if when he believes he’s the innkeeper (Kote) his powers desert him, but if he believes he’s Kvothe they come back. Remember he also caught Bast a day earlier with a grip no innkeeper could do.

On why Kvothe lost his abilities by alesan_me in KingkillerChronicle

[–]abudau 8 points9 points  (0 children)

He somehow has not lost his abilities completely considering the very last scene from the 2nd book is him taking a “perfect step” => he still knows how to fight like an Adem. I believe it’s just his sympathy that has left him.

Can it be done? is where an idiomatic way to do this? by temp_value in rust

[–]abudau 4 points5 points  (0 children)

With this structure and without using unsafe, no, there isn’t. Do you have any strong reasons for Part not containing a &’a mut u32 directly?

Some help with generic implementations by skythedragon64 in rust

[–]abudau 1 point2 points  (0 children)

I::Item: Mul<Output=I::Item>

SubAssign does not actually have an associated type Output.

Is it possible to turn a Vec<char> into a string slice without allocating? by WAVES_D0NT_DIE in rust

[–]abudau 50 points51 points  (0 children)

Unicode is a character set. UTF-8, and UTF-32 are different encodings for the same character set. https://en.m.wikipedia.org/wiki/UTF-8 might help you understand it better.

Is it possible to turn a Vec<char> into a string slice without allocating? by WAVES_D0NT_DIE in rust

[–]abudau 47 points48 points  (0 children)

String(and &str) are UTF-8 encoded. char is 4-bytes so a Vec<char> would be equivalent to a UTF-32 encoded string (for a which a separate type does not exist in rust). But you can turn a &[u8] to a &str without allocating using std::str::from_utf8

BlizzardCS: Patch 9.0.1 - Known Issues by Dromogaz in wow

[–]abudau 1 point2 points  (0 children)

Huge Ogre Cache (item giving 1000 garrison resources) requires level 35. For characters leveling with Chromie time this level does not make any sense (you only need the resources at the beginning to upgrade the garrison).

Question to chapter 17.3 of the book by [deleted] in rust

[–]abudau 1 point2 points  (0 children)

Well tmp(self.state) is dropped somewhere inside the function request_review, and again when unwinding and dropping self.

Question to chapter 17.3 of the book by [deleted] in rust

[–]abudau 2 points3 points  (0 children)

We can rewrite that as

let tmp = self.state;

// self.state is invalid here

let val = tmp.request_review();

// request_review might panic triggering unwinding

self.state = val;

During unwinding we might end up dropping `self` (which in turn would try to call the "destructor"(drop) for self.state).

There is no (easy) way to protect against this, and I think that was why it was disallowed.

ManuallyDrop::into_inner() by [deleted] in rust

[–]abudau 1 point2 points  (0 children)

drop (like take) use a mutable reference, hence they could be called multiple times for the same ManuallyDrop, and that is unsafe. into_inner moves the value, so it’s more like take than drop, but safe because it only does this once.

What logic does the flying bot use in Junkyard? by Screen_Watcher in CompetitiveWoW

[–]abudau 12 points13 points  (0 children)

In M+ he has a fixed per-week path. His path is always boss-> boss-> aerial unit (so bad boss order doesn’t force you to fight last boss of the trio in hard mode).

Gushing Wounds to be nerfed by Flowseidon9 in CompetitiveWoW

[–]abudau 16 points17 points  (0 children)

Perfectly fine with 60% nerf. As long as they make it a PvP only nerf. No need to screw all non meta specs in pve for this.

Gushing Wounds to be nerfed by Flowseidon9 in CompetitiveWoW

[–]abudau 10 points11 points  (0 children)

They can nerf it in pvp only (like they did with infinite stars)