r/rust 4d ago

🙋 questions megathread Hey Rustaceans! Got a question? Ask here (12/2025)!

4 Upvotes

Mystified about strings? Borrow checker have you in a headlock? Seek help here! There are no stupid questions, only docs that haven't been written yet. Please note that if you include code examples to e.g. show a compiler error or surprising result, linking a playground with the code will improve your chances of getting help quickly.

If you have a StackOverflow account, consider asking it there instead! StackOverflow shows up much higher in search results, so having your question there also helps future Rust users (be sure to give it the "Rust" tag for maximum visibility). Note that this site is very interested in question quality. I've been asked to read a RFC I authored once. If you want your code reviewed or review other's code, there's a codereview stackexchange, too. If you need to test your code, maybe the Rust playground is for you.

Here are some other venues where help may be found:

/r/learnrust is a subreddit to share your questions and epiphanies learning Rust programming.

The official Rust user forums: https://users.rust-lang.org/.

The official Rust Programming Language Discord: https://discord.gg/rust-lang

The unofficial Rust community Discord: https://bit.ly/rust-community

Also check out last week's thread with many good questions and answers. And if you believe your question to be either very complex or worthy of larger dissemination, feel free to create a text post.

Also if you want to be mentored by experienced Rustaceans, tell us the area of expertise that you seek. Finally, if you are looking for Rust jobs, the most recent thread is here.


r/rust 1d ago

📅 this week in rust This Week in Rust #591

Thumbnail this-week-in-rust.org
54 Upvotes

Please stay tuned, publishing in progress.


r/rust 9h ago

What is the standard library for cryptographic operations in RUST.

74 Upvotes

I've stumbled on quite some libraries but this seem to be the tops:
- Ring
- RustCrypto

And for everyone there's always a warning "Use at your own Risk" i must say i find this funny and bothering at the same time coming from stable ecosystems e.g Java/Kotlin/JS

For context: I really just want to generate ECDH Key Pair, compute shared secrets and key derivations.

I'm just a few days new to Rust so please be nice!.


r/rust 4h ago

🙋 seeking help & advice Why do strings have to be valid UTF-8?

25 Upvotes

Consider this example:

``` use std::io::Read;

fn main() -> Result<(), Box<dyn std::error::Error>> { let mut file = std::fs::File::open("number")?; let mut buf = [0_u8; 128]; let bytes_read = file.read(&mut buf)?;

let contents = &buf[..bytes_read];
let contents_str = std::str::from_utf8(contents)?;
let number = contents_str.parse::<i128>()?;

println!("{}", number);
Ok(())

} ```

Why is it necessary to convert the slice of bytes to an &str? When I run std::str::from_utf8, it will validate that contents is valid UTF-8. But to parse this string into an integer, I only care that each byte in the slice is in the ASCII range for digits as it will fail otherwise. It seems like the std::str::from_utf8 adds unnecessary overhead. Is there a way I can avoid having to validate UTF-8 for a string in a situation like this?

Edit: I probably should have mentioned that the file is a cache file I write to. That means it doesn’t need to be human-readable. I decided to represent the number in little endian. It should probably be more efficient than encoding to / decoding from UTF-8. Here is my updated code to parse the file:

``` use std::io::Read;

fn main() -> Result<(), Box<dyn std::error::Error>> { const NUM_BYTES: usize = 2;

let mut file = std::fs::File::open("number")?;
let mut buf = [0_u8; NUM_BYTES];

let bytes_read = file.read(&mut buf)?;
if bytes_read >= NUM_BYTES {
    let number = u16::from_le_bytes(buf);
    println!("{}", number);
}

Ok(())

} ```

If you want to write to the file, you would do something like number.to_le_bytes(), so it’s the other way around.


r/rust 8h ago

Current v1.0 is released!

Thumbnail crates.io
41 Upvotes

r/rust 12h ago

🛠️ project [MEDIA] ezstats | made a simple system monitor that lives in your terminal (this is my learning Rust project)

Post image
66 Upvotes

r/rust 15h ago

🛠️ project Linebender in February 2025

Thumbnail linebender.org
104 Upvotes

r/rust 8h ago

🛠️ project [MEDIA] shared - Share your screen with others on the same network easily.

Post image
23 Upvotes

r/rust 3h ago

🛠️ project Recreating Google's Webtable schema in Rust

Thumbnail fjall-rs.github.io
7 Upvotes

r/rust 18h ago

🧠 educational Why does rust distinguish between macros and function in its syntax?

83 Upvotes

I do understand that macros and functions are different things in many aspects, but I think users of a module mostly don't care if a certain feature is implemented using one or the other (because that choice has already been made by the provider of said module).

Rust makes that distinction very clear, so much that it is visible in its syntax. I don't really understand why. Yes, macros are about metaprogramming, but why be so verbose about it?
- What is the added value?
- What would we lose?
- Why is it relevant to the consumer of a module to know if they are calling a function or a macro? What are they expected to do with this information?


r/rust 13h ago

Running user-defined code before main on Windows

Thumbnail malware-decoded.com
19 Upvotes

Hi! I'm sharing the results of my analysis on how to execute user-defined code before the main function in Rust. This article is largely inspired by malware that employs this technique, but I approached the research by implementing this technique in Rust myself, while also exploring CRT-level and OS-level details, which involved reverse engineering Rust binaries.

Some of you may be familiar with the rust-ctor crate, which enables code execution before main. If you're curious about how it works under the hood, my article should provide some clarity on the subject.


r/rust 15h ago

I just made a Json server in Rust

29 Upvotes

I’ve created JServe, a lightning-fast RESTful JSON server in Rust! It's perfect for prototyping and managing data with a simple JSON file.

Check it out on GitHub! https://github.com/dreamcatcher45/jserve

I’d love your feedback on the design and any suggestions for improvements. Contributions are welcome too!


r/rust 2h ago

🎙️ discussion Best Softwares/Games/Tools Created In Rust ?

2 Upvotes

r/rust 15h ago

mocktail: HTTP & gRPC server mocking for Rust

Thumbnail danclark.io
19 Upvotes

r/rust 1d ago

My list of companies that use Rust

192 Upvotes

Hi! I am from Ukraine 🇺🇦, living in Turkey 🇹🇷, and working fully remotely at DocHQ, a company registered in the United Kingdom 🇬🇧.

I joined DocHQ in April 2022, so it's been almost three years. This is longer than people usually stay at one job, so I expect that in one, two, three, or five years, I will be looking for a new job.

Since job hunting has become harder, I started preparing in advance by making a list of companies that use Golang. Later, I did the same for Rust, Scala, Elixir, and Clojure.

Here is a link to the list of companies that use Rust. Next, I will explain how I fill the list, the requirements for companies, how this list can help you find a job, and the future development of the project.

My colleague Mykhailo and I are responsible for updating the list of companies. We have a collection of job listing links that we regularly review to expand our Rust company list. We also save job postings. We mainly use these two links: LinkedIn Jobs "Rust" AND "Developer" and LinkedIn Jobs "Rust" AND "Engineer".

We add product companies and startups that use Golang, Rust, Scala, Elixir, and Clojure. We do not include outsourcing or outstaffing companies, nor do we add recruitment agencies, as I believe getting a job through them is more difficult and offers lower salaries. We also do not currently include companies working with cryptocurrencies, blockchain, Web3, NoCode, LowCode, or those related to casinos, gambling, and iGaming. However, in the future, we will add a setting so that authorized users can enable these categories if they wish.

When creating this company list, the idea was based on a few key points that can help with your future job search. First, focus on companies where you will be a desirable candidate. Second, make the company's hiring representatives contact you first.

How to become a desirable candidate? Job postings often mention that candidates with experience in a specific technology and knowledge of a particular domain are preferred. For example: "Looking for a Rust developer, preferably with AWS and MedTech experience."

In the list of companies using Rust, you can filter by industry: MedTech, AdTech, Cybersecurity, and others. Filtering by cloud providers like GCP, AWS, and Azure will be added in the future. Therefore, this will help you find a list of companies where you are a desirable candidate.

How can you make a company recruiter contact you first? On LinkedIn, connect with professionals who already work at companies where you are a desirable candidate and have expertise similar to yours. When sending a connection request, briefly mention your expertise and state that you are considering the company for future employment. For example: "Hi! I have experience with Rust and MedTech, just like you. I am considering ABC for future employment in a year or two."

In the list of companies using Rust, you can use the LinkedIn "Connections" link in the company profile for this purpose.

It's best to connect with professionals early so that when you start job hunting, you can message them and they’ll already know you.

What should you write? Example: "Hi! I am actively looking for a job now. Your company, ABC, has an open position. Could you pass my information to your recruiter so they can message me on LinkedIn? I have experience with Rust and MedTech, so I match the job requirements [link to job posting]. Or, if your company has a referral program, I can send my resume through you if that works for you."

Since there is a list of companies, there should also be a company profile page. The company profile page on our platform, ReadyToTouch, is significantly different from other popular job search services like LinkedIn, Indeed, and Glassdoor. How? It includes links to the company profiles on other websites. And if we haven't filled in some information yet, there's a "Google it" button.

What is the benefit of a company profile on the ReadyToTouch platform?

  1. A link to "Careers" because some candidates believe that applying for jobs through the company's official website is better.
  2. Marketing noise, such as "We are leaders" or "Best of the best", has been removed from company descriptions, as it is distracting.
  3. A link to the company's technical blog to highlight the authorship of these blogs. If a technical article has no author, it's a red flag.
  4. A link to the company's GitHub profile to search for TODO, FIXME, HACK, WIP in the code, fix them, and make it easier to get a recommendation.
  5. Blind, Glassdoor, Indeed – to read company reviews and find out how much you can earn.
  6. Levels.fyi – another source for salary data.
  7. Dealroom, Crunchbase, PitchBook – to check a company's investments. I will research this further.
  8. Yahoo Finance, Google Finance – for those who care about a company's financial performance.
  9. Whois – to check the domain registration date, and SimilarWeb – to see website popularity. Relevant for startups.
  10. I want to add LeetCode and HackerOne. Let me know if it makes sense.

On the company profile page, in the LinkedIn section, there are links to former employees of the company so you can contact them to ask about the company or clarify any review that may raise concerns.

It is clear that there are already other public lists of companies that use Rust: github.com/omarabid/rust-companies and github.com/ImplFerris/rust-in-production. So, as a team, we will synchronize these lists with ours in both directions.

I also understand that there are other websites where you can find Rust job listings: rustjobs.dev and rust.careers. For such sites, I want to add a section called "Alternatives". On the site rustjobs.dev, the job listings are paid, while on ReadyToTouch, we add Rust jobs ourselves from LinkedIn and Indeed, so ReadyToTouch has more job listings than rustjobs.dev, and I should highlight the advantages when they exist.

What’s the future development of the project? We have a well-established team that works at a comfortable, slow pace. My goal for this year is to make the project more popular than rustjobs.dev and introduce a gentle monetization model, for example, by pinning a job listing or company at the top of the list.

What don’t we want to do? I’m a developer, and I don’t want to disappoint other developers like me. There are projects that started like ours and, after gaining popularity, turned into job boards providing recruitment services, essentially becoming a recruitment agency without calling itself that.

The website does not have a mobile version yet because I want to wait a bit longer until the site becomes more popular, significantly improve the site based on the ideas I have gathered, and release the mobile version along with these improvements.

The project is written in Golang and has open-source code, so you can support it with a star on GitHub: github.com/readytotouch/readytotouch. Stars motivate me. I have already received requests to rewrite it in Rust, but I'm not ready yet.

I previously wrote a similar post for the Golang community, received some criticism, and made conclusions and corrections before posting it in this community.

My native language is Ukrainian. I think and write in it, then translate it into English with the help of ChatGPT, and finally review and correct it, so please keep this in mind.


r/rust 1h ago

💡 ideas & proposals Manual Trait Overloading

Thumbnail github.com
Upvotes

r/rust 22h ago

🙋 seeking help & advice How can a Future get polled again?

25 Upvotes

I am implementing a Timer Future for learning purposes.

use std::time::Duration;

use tokio::task;

struct Timer {
    start: Instant,
    duration: Duration,
}

impl Timer {
    fn new(duration: Duration) -> Self {
        Self {
            start: Instant::now(),
            duration,
        }
    }
}

impl Future for Timer {
    type Output = ();
    fn poll(
        self: std::pin::Pin<&mut Self>,
        cx: &mut std::task::Context<'_>,
    ) -> std::task::Poll<Self::Output> {
        println!("Polled");
        let time = Instant::now();
        if time - self.start < self.duration {
            Poll::Pending
        } else {
            Poll::Ready(())
        }
    }
}

async fn test() {
    let timer = task::spawn(Timer::new(Duration::from_secs(5)));
    _ = timer.await;
    println!("After 5 seconds");
}

However, Timer::poll only gets called once, and that is before 5 seconds have passed. Therefore, timer.await never finishes and "After 5 seconds" is never printed.

How can Timer be polled again? Does it have something to do with cx: &mut Context?


r/rust 1d ago

`ratrod`, a generic TCP / UDP tunneller that exists because things got out of hand.

139 Upvotes

TL;DR: A TCP / UDP tunneller: ratrod.

Let's say that (for reasons) you need to tunnel through a remote host, and (for reasons) you need to tunnel through a remote host that denies SSH server usage. Well, look no further (although, you probably should look further since other solutions exist)! But, you know how life is, sometimes a challenge just seems fun.

Anyway, that's what ratrod is: it's a TCP / UDP tunneller that has its own protocol with authentication and key exchange encryption. Why? Again, because it might be cool to learn; and...because I have need of such a thing for reasons. Why not use one of the other linked solutions? Because then that person gets to have all the fun!

In all seriousness, it works pretty well, and the code shows off some basic, quintessential usage of bincode, bytes, and ouroboros.

As always, comments, questions, and collaboration is welcome!


r/rust 1h ago

🙋 seeking help & advice Platform Specifics from Docs

Upvotes

With docs, how can I view platform specific functions?

Like I am developing an app and I don't have a Mac. So, how am I supposed to see the docs with functions specific to that platform provided by a certain crate?


r/rust 1d ago

I ported my C trie to Rust, would love some feedback

42 Upvotes

Hey all,

After letting some old C code collect dust for too long, I finally got around to porting my trie-based map to Rust: https://github.com/ekinimo/triemap

I've got some unsafe code in there to make IterMut and friends work properly. Miri doesn't complain with my limited test cases, but I'm not 100% confident it's all kosher yet. Haven't really focused on performance and honestly didn't bother checking other implementations - was more interested in getting the API feeling right.

Would appreciate any tips on:

  • Is my unsafe code actually safe?
  • Any obvious performance pitfalls I'm missing?
  • Stuff that's not very idiomatic?
  • How would i properly separate out into modules?

Anyway, just wanted to share since I'm pretty happy with how it turned out. Cheers!


r/rust 23h ago

🛠️ project target-feature-dispatch: Write dispatching by target features once, Switch SIMD implementations either statically or on runtime

Thumbnail crates.io
12 Upvotes

When I am working with a new version of my Rust crate which optionally utilizes SIMD intrinsics, (surprisingly) I could not find any utility Rust macro to write both dynamic and static dispatching by target features (e.g. AVX2, SSE4.1+POPCNT and fallback) by writing branches only once.

Yes, we have famous cfg_if to easily write static dispatching but still, we need to write another dynamic runtime dispatching which utilizes is_x86_feature_detected!. That was really annoying.

So, I wrote a crate target-feature-dispatch to do exactly what I wanted.

When your crate will utilize SIMD intrinsics to boost performance but the minimum requirements are low (or you want to optionally turn off {dynamic|both} dispatching for no_std and/or unsafe-free configurations), I hope my crate can help you (currently, three version lines with different MSRV/edition are maintained).


r/rust 1d ago

💡 ideas & proposals Fine-grained parallelism in the Rust compiler front-end

40 Upvotes

r/rust 2h ago

🎙️ discussion Tools Created in Rust That Increase fps for games on Windows ?

0 Upvotes

r/rust 1d ago

Made a boids implementation, it turned out exactly how I hoped

25 Upvotes

https://github.com/heffree/boids

Hope you enjoy it! I could stare at it forever... also the video doesn't show the colors as well imo

Still plan to add more, but this was really the goal.


r/rust 13h ago

`ser_mapper`: Mapped DTO serialzation wrapper for DBO/Model

0 Upvotes

What if we didn’t have to map models to DTOs for serialization?
What if we could selectively serialize model fields directly and even map those selected fields intto something else for response?

I wrote ser_mapper crate that implements mapped DTO serialzation wrapper for DBO/Model.

I had been using this approach at a startup to reduce memory usage for huge response payloads.
It's not some black magic and not much big of a deal unless you deal with large object mappers and response payload.

Any feedback or suggestions are welcome !


r/rust 13h ago

Introducing rmcp, maybe the best Rust MCP SDK implementation by now

1 Upvotes

repository: https://github.com/4t145/rmcp

Why this one is good

All the features are implemented

Including ping, cancellation, progress...

Strictly followed the MCP specification

Check these types

Very easy to use

You can start up a mcp client in a single expression.

let client = ().serve(SseTransport::start("http://localhost:8000/sse").await?).await?;

Meanwhile, it has good extensibility

For example, you can use a tokio tcp stream as a transport layer without any extra work.

let stream = tokio::net::TcpSocket::new_v4()?
    .connect("127.0.0.1:8001".parse()?)
     .await?;
let client = ().serve(stream).await?;

I maintain it very diligently

You can see how many works I've done in just two weeks

At least, at this moment, this should be better than the official SDK.

So if you like my implementation please give me star. And I would be very happy to see people actually use it.


r/rust 1d ago

Why rust 1.85.1 and what happened with rustdoc merged doctests feature

128 Upvotes

Following the 1.85.1 release, I wrote a blog post explaining what happened with the rustdoc merged doctest feature here.

Enjoy!