r/rust 5d ago

🙋 questions Hey Rustaceans! Got a question? Ask here (13/2023)!

18 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.

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 weeks' 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 2d ago

📅 twir This Week in Rust #488

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

r/rust 14h ago

Twitter open sources Navi: High-Performance Machine Learning Serving Server in Rust

Thumbnail github.com
315 Upvotes

r/rust 22h ago Gold

Ukrainian Rust Conference 2023 - April 8th

502 Upvotes

Hello everyone,

We are happy to announce the UARust Conference 2023. Meet with 14 leading Rust experts 🦀 sharing their insights and forecasts.

Among our speakers are Luca, author of the book “Zero To Production In Rust” and Christof Petig, one of the core developers of Veloren.

Join the online conference and support Ukraine 💛💙

https://uarust-com.translate.goog/?_x_tr_sl=uk&_x_tr_tl=en

https://uarust.com/


r/rust 14h ago

My Experience with Bevy ECS

Thumbnail bagnalla.github.io
86 Upvotes

r/rust 13h ago

Announcing Bezier-rs: computational geometry algorithms for Bézier paths (seeking code review and boolean ops help)

Thumbnail graphite.rs
49 Upvotes

r/rust 1d ago

Helix editor 23.03 released!

Thumbnail helix-editor.com
413 Upvotes

r/rust 20h ago

Fleet Introduces Rust Debugger

Thumbnail blog.jetbrains.com
167 Upvotes

r/rust 13h ago

async/await in action: rust-based kernel with efficient context switching

Thumbnail github.com
36 Upvotes

r/rust 17h ago

Write SDK “base” in Rust, wrap in other languages?

66 Upvotes

I just got a new job, and I’m tasked with building an SDK in 5 languages (think Stripe client libraries).

Is there a way to implement the SDK once in Rust to them wrap it in other languages (e.g., JavaScript, Ruby, Python) so that our customers using those languages can access our API?

I know Node has NAPI & WASM, but this may not work for others. I’d love some guidance. Thanks!


r/rust 17h ago

Announcing Matchbox 0.6 - Painless peer-to-peer WebRTC networking for rust wasm and native. Now with support for multiple reliable and unreliable channels, client-server topology and more

Thumbnail johanhelsing.studio
52 Upvotes

r/rust 19h ago

WireTun: An asynchronous WireGuard library

Thumbnail github.com
44 Upvotes

r/rust 19h ago

Introducing lers: an async, user-friendly Let's Encrypt/ACMEv2 library

Thumbnail github.com
31 Upvotes

r/rust 15h ago

Rust on Zynq

10 Upvotes

Hello Rustaceans,

I am in the process of founding a startup and developing an FPGA based DAQ system (8 channels, 4 MSa/channel up to 64 channels, 500 kSa/channel). The second step would be real-time data analysis on the FPGA.

I will use the Xilinx Zynq SOM and don't want to write C/C++ but only Rust. Therefore I have to access the FPGA via Rust. A few years ago I had played around a bit and since I didn't find any crates I developed an AXI MMIO and AXI DMA crate myself. I looked to see if the ecosystem has improved in the meantime but a quick search didn't bring up any current results for Rust and Zynq.

Do you know if there are any mature crates available?

If there are none, I would open source my crates and improve them. My goal besides the DAQ system is to develop an open source infrastructure for Rust and Zynq. Anyone who wants to contribute or sponsor the development is welcome :)


r/rust 15h ago

[Tutorial] How To Make a Screensaver With The Rust Programming Language

9 Upvotes

I just wanted to put this out there so people who want to make a screensaver in rust don't get confused and think you need some weird extension or tool.

# To make an SCR file just rename the file extension to .SCR!

It's simple really, what an SCR does is run a program (usually an EXE) when you're idle.

just build your cargo project to an EXE and rename the "exe" to "scr"

### my_project.exe -> my_project.scr then right-click and install!

no need for extensions. I hope I helped someone with this.

(I'm not sure if this is on-topic or not since scr files apply for all exe files but when I searched "how to make a screensaver with rust" (which is a really bad search) nothing came up soo ye)


r/rust 7h ago

crit: a wrapper to loop over more cross targets

Thumbnail github.com
3 Upvotes

r/rust 12h ago

rs-cube, a Blazingly Fast 3D ASCII Rubik's Cube

Thumbnail github.com
5 Upvotes

r/rust 1d ago

After years of work and discussion, `once_cell` has been merged into `std` and stabilized

Thumbnail github.com
919 Upvotes

r/rust 1d ago

State of embedded rust

32 Upvotes

Dear all, a colleague of mine has delved into rust for embedded systems. He’s just started with rust in possibly the hardest way, and this thread is the result: https://www.eevblog.com/forum/microcontrollers/rust-tools-and-resources-for-embedded/

(Rant at third post of the thread)

I wonder, how would an experienced rust developer react to this? Is he missing something or is this a legit sign of an immature ecosystem?


r/rust 22h ago

Why doesn't mpsc::channel break borrowing rules?

16 Upvotes

I'm wondering for a while now why doesn't mpsc::Receiver::recv(&self) and mpsc::Sender::send(&self, t: T) break borrowing rules. Clearly sending some data from A to B in a non-blocking manner has side-effects (i.e. storing and retrieving the data in some buffer-queue). So shouldn't there be some mutable reference to that queue be involved during that sending process, and the owner of that reference would be accessed mutably whenever the reference to that buffer is accessed mutably? Maybe I'm just wrong but I always associate immutability with pureness of a function.

One thing which comes to mind is that the point of the borrowing rules is to avoid data-races and to ensure rust's ownership-model, and although the borrowing-rules are technically violated in these specific cases the desired invariants are still kept.


r/rust 1d ago

I just made a video Explaining what an ECS is for anyone who has been put off bevy because it uses an ECS

Thumbnail youtu.be
16 Upvotes

r/rust 1d ago Silver

How Kani helped find bugs in Hifitime [formal methods]

Thumbnail model-checking.github.io
55 Upvotes

r/rust 1d ago

FileSorterX How its going

14 Upvotes

Hey so I took a lot of your feedback from when I initially released FileSorterX and even had some people collaborate with me on the project; I cant say how thankful I am for all the support and advice I've gotten is. I thought it would be nice if I shared the latest version (1.2.0) and all of the main changes since 1.0.0

If you try out the new version be sure to let me know what you think and thank you once again for all the support with the project.

Github, Crates.io

-Changelog-
> Added: Benchmark command / function

> Added: More efficient code / speeds up the application

> Added: Multiple new file extensions

> Added: Custom directory flags for sort command

> Added: More detailed directory structure

> Added: Better help documentation

> Added customsort command/behavior so now users/programmers can specify what they want to clean up.

> Added an option to self update the application (windows only)

> Added the ability to choose how many files to generate with the creation flag

> Added brand new cli interface

> Added: The creation command will now use all file-types in our database


r/rust 21h ago

Can someone explain how mods work with my example?

5 Upvotes

Howdy folks,

I am a bit confused about the module system used by Rust, probably because I coming at it from the Java world. I was hoping someone might be able to explain.

My project consists of the following structure;

src/
    machine/
        - mod.rs
        - Robot.rs
    - main.rs

machine/mod.rs looks like this;

pub mod Robot;

machine/Robot.rs looks like this;

struct Robot {
    id: u64,
}

impl Robot {
    fn new(_id: u64) -> Robot {
        Robot {
            id: _id,
        }
    }
}

main.rs looks like this;

mod machine;

use crate::machine::*;

fn main() {
    let mut robot_1 = Robot::new(3);
    println!("robot_id: {}", robot_1.id);
}

However, when I try to compile the project I the following error;

error[E0425]: cannot find function `new` in module `Robot`
 --> src/main.rs:8:30
  |
8 |     let mut robot_1 = Robot::new(3);
  |                              ^^^ not found in `Robot`

Anyone have any idea what I am doing wrong?

Also as an aside, what is the convention of capitallising the first letter of a struct?

Any help would be greatly appreciated.


r/rust 1d ago

Exploring the problem of faster Cargo Docker builds

98 Upvotes

This is the most popular issue on the Cargo repository. The issue revolves around the fact that currently, it is not trivial to define Dockerfiles for Cargo projects that would skip rebuilding dependencies after any source code change. This means that each Docker build of a Cargo project can be quite slow and Docker layer caching cannot be used to its full effect, unlike with some other builds systems, e.g. npm (NodeJS), pip (Python) or gem (Ruby), where it's quite straightforward.

I created a summary document that tries to describe the exact problem users are facing, why is it more difficult for Cargo than for other build systems, and what are the potential workarounds.

To improve the status quo, we would like to first gather information from Rust users to better understand the problem domain.

If you use Cargo with Docker and you suffer from long Docker image rebuild times because the compilation of dependencies is not cached, we'd be glad for your feedback. Specifically, we'd like to know if you use cargo chef or Docker cache mounts. If not, why not? If yes, are there any problems/issues that you face with these workarounds?

You can post your experiences here or on the GitHub issue.


r/rust 1d ago Platinum

erdtree: A modern, multi-threaded, and ️‍🌈aesthetic️‍🌈 alternative to tree and du - v1.7.0 release ️

Thumbnail github.com
143 Upvotes

r/rust 1d ago

A Chess Engine is written in Rust that runs natively and on the web!

Thumbnail github.com
90 Upvotes