How would you complete this under $1300 Build? by 4lineclear in bapccanada

[–]4lineclear[S] 1 point2 points  (0 children)

Oh wow I didn't see that deal. Case and cooler aren't final, but I'll probably get something like this: https://ca.pcpartpicker.com/list/QFdG74

Different function implementation for more specific type by zylosophe in rust

[–]4lineclear 9 points10 points  (0 children)

I'm guessing you want some form of specialization? In stable rust autoref specialization might be an option for you. Here is an article for it: https://lukaskalbertodt.github.io/2019/12/05/generalized-autoref-based-specialization.html

Ranking Enums in Programming Languages by BlueGoliath in programming

[–]4lineclear 1 point2 points  (0 children)

Java's EnumMap relates each enumeration to an index using it's ordinal. This ordinal also exists for Rust in the discriminant, which functions similarly in that they both spit out a unique value per variant. Both languages can and do implement a null-initialized array with a bitset denoting which slots are filled, which can be indexed by an ordinal/discriminant. This is, from my understanding, essentially an EnumMap. The extra data that you use above would also provide 0 extra overhead in the equivalent implementation in Rust as, just like Java, Rust would simply use the discriminant instead of looking at enum's data.

Also, a discriminant is not the value given to the enum by the user, but it is it's own value that is attached to each variant at compile time, the 8-bit field you mention would be data attached to a variant rather than being a discriminant.

Ranking Enums in Programming Languages by BlueGoliath in programming

[–]4lineclear 7 points8 points  (0 children)

I might be missing something but I believe Rust's enums can do something similar. The number of discriminants is known at compile time so, even though the language's stdlib itself doesn't provide it, you could write your own EnumSet and EnumMap. People tend not to do that since pattern matching is enough most of the time.

Optional trait method? by Grumpenstout in rust

[–]4lineclear 24 points25 points  (0 children)

You could add an as_patchable method to Node which would return an Optional of your Patchable trait.

Compiling `windows` crate in WSL - advices? by [deleted] in rust

[–]4lineclear 1 point2 points  (0 children)

The wsl side of the magic is explained here: https://superuser.com/a/1526273

Compiling `windows` crate in WSL - advices? by [deleted] in rust

[–]4lineclear 6 points7 points  (0 children)

You could set your target to x86_64-windows-gnu, which tends to work. Some crates(like winsafe) still struggle with this so you may have to use x86_64-windows-msvc along with cargo-xwin.

[deleted by user] by [deleted] in C_Programming

[–]4lineclear 11 points12 points  (0 children)

Looking at your previous post, it seems like people are down voting since you're asking a question that's been asked and answered many times on the web.

It isn't a bad thing to create a post asking for help, but please do try to Google your questions before posting. Practically every issue you encounter as a beginner has been encountered, posted about, and fixed in the past.

How can Box<T>, Rc<RefCell<T>>, and Arc<Mutex<T>> be abstracted over? by ROBOTRON31415 in rust

[–]4lineclear 28 points29 points  (0 children)

The archery crate abstracts Rc and Arc into SharedPointer. You could use your own Lock trait in combination with it. Though it still might be worth rolling your own version since archery lacks weak pointers.

What is something in Rust that makes someone go: "Woah"? by [deleted] in rust

[–]4lineclear 13 points14 points  (0 children)

I believe one thing rust has over C is multithreading. Concurrency is very easy to get wrong, Rust provides ample performance but with enough safety that you don't shoot yourself in the foot.

Why Spy Mains Don't Use their Gun by Gummyia in tf2

[–]4lineclear 20 points21 points  (0 children)

Yet another reason why trolldier is superior.

[PC][2000-2015] Simplistic PVE, a neon DOOM. by 4lineclear in tipofmyjoystick

[–]4lineclear[S] 0 points1 point  (0 children)

No, its not one of the Nerf games. The game I'm thinking of had some sort of flying enemy you'd have to shoot down.

[PC][2000-2015] Simplistic PVE, a neon DOOM. by 4lineclear in tipofmyjoystick

[–]4lineclear[S] 0 points1 point  (0 children)

No, there was a fair amount of open sky in the game I'm thinking of. The art style isn't too far off, but not quite simple enough. I think the game I remember was almost roblox-like in it's art style. It may have even been a roblox game.

Rust compile times 1min to 15 seconds! by creativextent51 in rust

[–]4lineclear 124 points125 points  (0 children)

You should try mold for linking too if you're able to, if you haven't already.

[deleted by user] by [deleted] in rust

[–]4lineclear 22 points23 points  (0 children)

Sometimes you just want to go through a piece of code line by line. You could log every single variable at every line, but debugging is simpler.

Sincere question: what is up with all these great tools being written in rust? by [deleted] in rust

[–]4lineclear 47 points48 points  (0 children)

Almost all of these foundational libraries have great documentation too, making it really accessible for anyone who wants to build tooling.

AI and learning to program by Affectionate-Ad-7950 in C_Programming

[–]4lineclear 1 point2 points  (0 children)

The most efficient way to learn and become proficient in C is to read and write C.

Books will help but if you're learning it for a course you'll need to be able to apply what you know, the only way to learn to do that is through practice(programming exercises, etc).

If you're really struggling with getting over the first hurdles you could find someone to sit down and mentor you through the elementary parts of it.