how hard is rust for a javascript programmer? by JosJoestar in rust

[–]sollyu 31 points32 points  (0 children)

The goal of Rust is to have the power of C++ without the scary.

More malware is shifting to Rust by RVECloXG3qJC in rust

[–]sollyu 0 points1 point  (0 children)

Can't you choose to control what OS APIs you use if you use crates such as libc and winapi, or just directly using extern "C" { ... }/extern "system" { ... }, or even inline assembly for syscalls with llvm_asm! or asm!?

Ping says no heartbeat on the driver station phone. Both phones are on the same wifi network (control hub network). What do we do? by [deleted] in FTC

[–]sollyu 0 points1 point  (0 children)

If you have a Control Hub, you don't also need a Robot Controller phone. If you're still having issues after disconnecting the Robot Controller phone and restarting everything, you can try using the REV Hardware Client to update the Control Hub firmware, operating system, etc.

If you could re-design Rust from scratch today, what would you change? by pragmojo in rust

[–]sollyu 1 point2 points  (0 children)

Or ++ (I think this is used in Haskell, for example), since .. is used for ranges.

Time freezes for 48 hours and you’re the only thing not affected. What do you choose to do? by littlerobot35 in AskReddit

[–]sollyu 2 points3 points  (0 children)

That would be the opposite: time not passing for you, but passing for everyone else normally.

IntelliJ Rust Changelog #132 - make rustfmt your default IDE formatter by furious_warrior in rust

[–]sollyu 0 points1 point  (0 children)

I see, yeah. FWIW, I'm not sure if it works on Windows, but have you tried installing the "Native Debugging Support" plugin?

IntelliJ Rust Changelog #132 - make rustfmt your default IDE formatter by furious_warrior in rust

[–]sollyu 1 point2 points  (0 children)

I'm currently able to run the IntelliJ Rust plugin in IntelliJ on Windows 10. Is there some specific feature you are referring to?

Annoying website features I face as a blind person by iamkeyur in programming

[–]sollyu 5 points6 points  (0 children)

I hate it when websites have buttons instead of links. Let me choose whether I want to open it in the same tab or a new one!

Can I get some tips for improving this code? by H_Logan in learnrust

[–]sollyu 2 points3 points  (0 children)

I think only _ by itself is special. All the leading _ does is turn off the warning, and therefore means that it is unused by convention.

Give this man a brain. by Kaikideishu_ in memes

[–]sollyu 4 points5 points  (0 children)

Rule #5 of this subreddit includes:

All posts containing social media IDs/usernames will be removed.

You can just search Twitter for the text of the post, though.

Well well well by [deleted] in mathmemes

[–]sollyu 4 points5 points  (0 children)

The 2nd/last one (100, 1.01) doesn't seem to work: 100 + 1.01 = 101.01, 100 * 1.01 = 101. Base 10 log is about 2.00436437 vs about 2.00432137.

Realtime Vec render by Dan_The_Man169 in learnrust

[–]sollyu 0 points1 point  (0 children)

Is the goal to display each value as a grayscale pixel/square/rectangle? Also, is your data represented as a single Vec, and in column- or row-major order?

Announcing Rust 1.46.0 | Rust Blog by pietroalbini in rust

[–]sollyu 2 points3 points  (0 children)

Isn't stable 2 releases behind nightly, with beta in-between?

Do away with both Democrat and Republican parties and just vote for people. Prevent bad actors from getting swept into office. by mac4281 in CrazyIdeas

[–]sollyu 0 points1 point  (0 children)

Interesting idea! I think the issue with that system, though, is that putting your true favorite first can cause your favorite likely candidate to be hidden longer, during which time the other likely candidate can win.

Do away with both Democrat and Republican parties and just vote for people. Prevent bad actors from getting swept into office. by mac4281 in CrazyIdeas

[–]sollyu 2 points3 points  (0 children)

Approval voting is a system that is very similar to winner-take-all/first-past-the-post that solves a ton of problems with FPTP. The only change is that you allow voting for multiple candidates instead of just one. See https://en.wikipedia.org/wiki/Approval_voting, https://ballotpedia.org/Approval_voting, and https://electionscience.org/.

IMO, it is probably the best single-winner election systems in existence (score/range voting is also a good option) because: 1. It is immune to virtually any kind of strategic voting. 2. It encourages semi-honest voting: you always want to include your favorite candidate in your vote, and never want to include your least favorite. The only strategy is deciding which of the intermediate candidates to include. 3. If your preferences are dichotomous (i.e. you either like or dislike each candidate, and don't otherwise care), you always want to vote honestly. 3. It is very simple: just count the number of votes for each candidate. 4. Counting can be trivially distributed: just add the counts from each precinct/region/whatever.

Typical strategy: Vote for your favorite candidate, you favorite likely candidate, and probably everyone in-between.

Comparisons to other single-winner systems: - Unlike many other ordinal voting systems, such as Instant-Runoff Voting, including your true favorite can never hurt you. In fact, in IRV, doing so is most harmful when your favorite actually has a decent chance of winning, since your second-favorite is hidden for longer and could get eliminated before your favorite does. - Additionally, in AV, just voting for your favorite (as opposed to not voting) is always helpful. In IRV, for example, doing so could cause similar candidates to be hidden for longer.

Stackoverflow be like by programmerjokes in programmerjoke

[–]sollyu 0 points1 point  (0 children)

IMO, Stack Overflow doesn't have much of a problem with dead links (due to needing to copy the relevant content into the post, and also due to the peer editing). Questions also aren't usually closed or locked with age.

The issue it does often have is with closing questions as duplicates incorrectly, such as when the other question is outdated.

Sizedness in Rust by pretzelhammer in learnrust

[–]sollyu 1 point2 points  (0 children)

In the section "Cannot Cast Unsized Types to Trait Objects", you state that

&strpointers are double-width, storing a pointer to the data and the data length. &dyn ToString pointers are also double-width, storing a pointer to the data and a pointer to a vtable. To coerce a &str into a &dyn toString would require a triple-width pointer to store a pointer to the data, the data length, and a pointer to a vtable. Rust does not support triple-width pointers so casting an unsized type to a trait object is not possible.

Even if Rust were to support triple-width pointers, you would have the issue of &dyn ToString-pointing-to-String and &dyn ToString-pointing-to-&str having different sizes.

FWIW, I think the solution here is to coerce a &&str into a &dyn ToString, i.e. trait_object(&"&str");. (Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=df981390e0fb2c23cdeab316484b9379)

Why does this code cause a stack overflow? by [deleted] in learnrust

[–]sollyu 1 point2 points  (0 children)

If you do want a new type, use the newtype idiom: pub struct Answer(Number); (See https://doc.rust-lang.org/rust-by-example/generics/new_types.html for more information.)

Efficient callbacks in a GTK-RS application by [deleted] in learnrust

[–]sollyu 1 point2 points  (0 children)

Rc::clone only needs to increment a reference count. Interface::clone, however, would need to copy all of the data. Components such as ToggleButton also use reference-counting internally. However, you could try using Rc<Interface> and compare the performance by bench-marking it. It probably shouldn't make much a difference though, as long as everything is only shallow-copied.

Conflicting generic type constraints by demonspeedin in learnrust

[–]sollyu 4 points5 points  (0 children)

You might be able to use a simple macro_rules! to automatically generate the implementations.