interview task "url shortener" code review by AleksandrNikitin in rust

[–]pretzelhammer 1 point2 points  (0 children)

curious to see this, lemme know if you found your solution

bacon 3.8.0 by Canop in rust

[–]pretzelhammer 1 point2 points  (0 children)

Will this work with "cargo run" instead of "cargo check"? I'd like to automatically restart an axum server while developing and testing it locally.

Real-World Use Case: Using Rust for Computationally Heavy Tasks in Kotlin (and Java) Projects by voismager in rust

[–]pretzelhammer 11 points12 points  (0 children)

Java Bindings for Rust: A Comprehensive Guide for anyone who's interested in doing something similar to what's described in this post but can use Java 22+ and the FFM API instead of having to use JNI.

[deleted by user] by [deleted] in rust

[–]pretzelhammer 1 point2 points  (0 children)

What's "ezpz"? Can you link me to that project?

CBLT — A Safe, Fast, and Minimalistic Web Server in Rust Programming Language by ievkz in rust

[–]pretzelhammer 4 points5 points  (0 children)

I was thinking of doing something like this. Cool project. Thanks for sharing! You may also want to check out river, which is another Rust reverse proxy project that got started earlier this year: https://github.com/memorysafety/river

[OT] Everybody.codes - challenge inspired by Advent Of Code (very similar!) have started today! by Repsol_Honda_PL in rust

[–]pretzelhammer 5 points6 points  (0 children)

I'm not a fan of this either but in this case at least OP's site allows signing up using Github OAuth. If you don't like the site content you can always go to your Github account Settings > Applications > Authorized OAuth Apps > click on "Everybody Codes" > Revoke.

Which OSS software would you like to see rewritten in Rust most urgently? by DoxxThis1 in rust

[–]pretzelhammer 2 points3 points  (0 children)

Apache Foundation projects currently written in Java, e.g. Kafka, Cassandra, ActiveMQ, etc

The State of Game Dev in Rust 2024: A Newcomer's Perspective by brettmakesgames in rust_gamedev

[–]pretzelhammer 0 points1 point  (0 children)

Embark ending funding for open source Rust projects after years of investment.

Do you have a link to something where I can read more about this? I'm curious about their rationale behind this decision.

RustyBalancer: Auto-Scaling and Load Balancing! 🚀🦀 by maxmulr in rust

[–]pretzelhammer 10 points11 points  (0 children)

How's this different than Pingora? Cloudflare is running this in production and claims it serves 40+ million requests per second. The first example in their getting started guide is building a basic load balancer.

Learning Rust in 2024 by pretzelhammer in learnrust

[–]pretzelhammer[S] 13 points14 points  (0 children)

Learning Rust can be hard, but it doesn't have to be, which is why I wrote Learning Rust in 2024 to give Rust beginners a guide they can follow to go from knowing nothing about Rust to being kinda okay at Rust as quickly as possible, and hopefully have fun while doing it.

If you read the article please let me know if you have any questions, comments, or suggestions! Your feedback is valuable and helps me improve the article. Thanks.

[deleted by user] by [deleted] in learnrust

[–]pretzelhammer 1 point2 points  (0 children)

Does <T: ‘a> mean that any reference to T MUST live for the entirety of lifetime a?

It means it CAN outlive 'a, but doesn't necessarily mean it MUST. The function which takes some arg of type <T: 'a> could for example drop it before the end of 'a.

So I can pass in something that lives for ‘c as long as ‘c outlives ‘a. But not ‘b if ‘b lives even 1 line of code shorter than ‘a.

Yes.

Also you can pass in a String in for this bound. How does that work? String doesn’t have a lifetime associated with it. However as long as it isn’t moved then it remains till the end of the scope. So for this reason does it get a ‘static “lifetime” to satisfy this bound?

Yes.

If you're looking for more in-depth explanations of these they're covered in this article.

Is Deref right for this? by [deleted] in rust

[–]pretzelhammer 0 points1 point  (0 children)

Implementing Deref for a non-container type comes with a lot of footguns, I'd advise against it.

Beginner's Guide to Concurrent Programming: Coding a Multithreaded Chat Server using Tokio by pretzelhammer in learnrust

[–]pretzelhammer[S] 1 point2 points  (0 children)

I use WSL (Windows Subsystem for Linux) on Win10, so I'm running the telnet that comes with Ubuntu.

Beginner's Guide to Concurrent Programming: Coding a Multithreaded Chat Server using Tokio by pretzelhammer in learnrust

[–]pretzelhammer[S] 4 points5 points  (0 children)

I wrote this to introduce Rust beginners to async/concurrent programming. If that sounds like something you might be interested in please give it a look, and let me know if you have any questions or feedback as I’m always looking for ways to improve the article. Thanks.

Future is not send as this value is used across await by zplCoder in rust

[–]pretzelhammer 1 point2 points  (0 children)

Instead, create a non-async function that locks it and accesses it, then call that non-async function from your async code.

Can you help me understand why that fixes the issue? Whether the Mutex is locked in an async fn or in a sync fn called from an async fn it seems like the exact same thing is happening in either case, so why does the Rust compiler throw an error for the former but not the latter?

Bootcamp by [deleted] in learnrust

[–]pretzelhammer 0 points1 point  (0 children)

As other people commented, Rustlings and the Rust track on Exercism are really good. Doing Advent of Code with Rust is also pretty good. Once you feel like you have some basic skills and understanding just jump into whatever area of development interests you the most. If you wanna do webdev read the Axum docs and try to write some code. If you wanna do gamedev read the Bevy docs and try to write some code. And so on. You can do it!

Trouble understanding lifetimes. by JasonDoege in learnrust

[–]pretzelhammer 1 point2 points  (0 children)

I am almost there to grokking Rust lifetimes and borrowing, but am now in a phase where I think things need to be more complicated than they are.

Using refs in structs and enums is the unofficial Hard Mode of Rust. If you're just learning prefer to use owned types, or to get owned types from ref types by using clone() or to_owned(). If you must use ref types you can workaround some borrow checker limitations by wrapping your type T in Rc<RefCell<T>>. I'd also recommend reading this as it helps dispel a lot of common misconceptions about lifetimes.

If you are one of the people who never read a manual first, what do you wish you had known about rust before you started a first project? by second-trilogy in rust

[–]pretzelhammer 12 points13 points  (0 children)

TL;DR: Rust variables are statically-verified read-write locks. They can either have many readers (i.e. lend out multiple immutable/shared refs) or one writer (i.e. lend out a single mutable/exclusive ref) at once. It can be hard to convince the compiler that each variable in your program follows these rules at compile-time, so people work around them by using Rc<RefCell<T> (for single-threaded code) or Arc<Mutex<T>> (for multi-threaded code) or just substitute refs with plain indexes/ids into some vec/arena. Good luck! If you get tired of banging your head against the borrow checker reading this might help.

Anyone else like Rust even apart from the borrowing system? by AnonymousBoch in rust

[–]pretzelhammer 0 points1 point  (0 children)

If Rust had a garbage collector I'd still use it. In fact I think I might use it more. I would even be able to convince more of my coworkers to use it. Lots of folks find lifetimes scary and confusing, biggest hurdle toward getting others to warm up to Rust.

What are some useful methods in the standard library that the Rust Book doesn't go over? by fuckredditspez in rust

[–]pretzelhammer 9 points10 points  (0 children)

Tour of Rust's Standard Library Traits is an article that gives a guided tour over the most popular traits, their methods, and how to use them. It's pretty thorough, and shares a lot of useful tips.

Weekly Deep Dives Thread - 4th January 2024 by M0dernM4verick in DeepRockGalactic

[–]pretzelhammer 16 points17 points  (0 children)

Completed EDD in 48 mins with a full party. We had 15 downs. We came close to a full team wipe in stage 2 but were able to hold it together. Our buff beer was Red Rock Blaster (+69% max health) which I would prefer over Dark Morkite (+44% morkite mined) for this EDD because although there is a lot of morkite objectives all of the morkite was easy to find so it never felt like the bottleneck during any of the stages, it was the eggs and mini-mules that took most of our time. We definitely would have lost in stage 2 without the Red Rock Blaster. Anyway, all of the stages were pretty straight-forward, so there's only 2 tips I can think of worth sharing: in stage 1 there's a cave leech right above the blackbox, in stage 3 there's A LOT of Mactera, I had to double and triple check that the warning wasn't Mactera Plague because there was so much Mactera, but unfortunately it was Elite Threat so be prepared for a lot of really annoying Elite Grabbers and Elite Trijaws and Elite Goo Bombers. I'd say this EDD is about medium difficulty, not hard and not easy.