The Rust Programming Language

47 readers
1 users here now

A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and...

founded 1 year ago
MODERATORS
1
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/GankraAria on 2024-04-09 17:54:09.

2
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/TrueSgtMonkey on 2024-04-10 03:57:29.


One thing I noticed about tutorials for Rust on YouTube is their constant need to "sell" Rust. I get it, this is a memory safe and performant language.

I also get it. Certain features are done certain ways because they are memory safe and/or performant.

But, I do not need to hear all of this on every video.

For example, Let's Get Rusty spends 1/3 of *each* video talking about how good Rust is when he could spend it actually teaching something.

Are there any video tutorial series that just stick to the lesson plan?

If you try to learn most languages, they don't spend most of the video trying to sell that language. They actually teach.

I love the language by the way. Also, the book is awesome, but sometimes I want something more visual.

Edit: The main reason I do not need to hear all of this on every video is because I am already sold on the language. I really enjoy programming with it and want to learn more about it.

But, these tutorials are like hearing advertisements for the show you are watching baked into every episode. It just gets tiring after a while.

My hope is for some content creators to see this post.

3
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/dochtman on 2024-04-09 20:43:58.

4
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/StalwartLabs on 2024-04-09 18:15:05.


Hi,

Just wanted to announce to the community that a new version of Stalwart Mail Server (the open source mail server written in Rust) has now been released featuring a web-based admin tool which was, of course, also written in Rust! The chosen framework was Leptos and the UI components are from Preline.

I also wanted to quickly share my experience developing a webapp with Rust. I hadn't done any web development since the JQuery days and, being mostly a backend developer, I was dreading the moment. To my surprise it has been a real pleasure not having to deal with Javascript and being able to develop every single aspect of the application logic with Rust.

Thanks!

5
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/emilern on 2024-04-09 17:43:32.

6
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/pietroalbini on 2024-04-09 19:08:15.

7
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/yoshuawuyts1 on 2024-04-09 17:47:05.

8
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/Prom3th3an on 2024-04-09 08:38:36.

9
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/Worth_Talk_817 on 2024-04-09 16:09:25.


I recently did a full overhaul of my documentation for a crate I wrote. I was wondering if it's fine to push a new version to crates.io, or if it should be avoided. Also, is there any way to update my docs on docs.rs without publishing to crates?

I just notice whenever I push a new version I get a ton more downloads and it feels manipulative to push a new version when all I've changed is docs.

10
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/DynaBeast on 2024-04-08 19:59:23.


View Poll

11
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/roll4c on 2024-04-09 08:00:28.


fn perform\_lookup(
 &mut self,
 table\_id: u32,
 keys: &[Variable; KEYS],
) -> [Variable; VALUES]
where
 [(); KEYS + VALUES]:;

The source code is here.

12
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/Revolutionary_Gap887 on 2024-04-08 20:13:18.


This is a short blog of my learning of phantom data while I was working on a project to create invoices. There are many approaches to code reuse, i today chose generics and phantom data popped up. I quite liked the final outcome and hence created a post on it

13
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/Ved_s on 2024-04-09 05:04:38.

14
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/GyulyVGC on 2024-04-08 14:33:35.


Sniffnet is a Rust-based network monitoring tool I’ve been working on for almost two years now.

Exactly 8 months after the previous release, I’m excited to share that today Sniffnet v1.3.0 has been published.

This release introduces several long requested features, such as export of PCAP files, support for ICMP, detection of more upper layer services, and other functionalities to improve the overall user experience, such as the new thumbnail mode and the possibility to totally customize the application color palette.

I’ve also dedicated some efforts to enhance Sniffnet documentation and I’ve come up with a complete user manual hosted on GitHub Wiki.

As usual, feedbacks are warmly appreciated!

15
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/gendix on 2024-04-08 19:21:54.

16
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/pndc on 2024-04-08 19:25:40.

17
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/chrisbiscardi on 2024-04-08 17:44:22.

18
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/InternalServerError7 on 2024-04-08 11:17:55.


Following a recent discussion on reimagining Rust, many voiced the need for more terse error handling. While anyhow and thiserror serve their purposes, each comes with its trade-offs. This got me thinking: Is there a middle ground that combines flexibility with precision?

Enter error_set a concept derived from Zig that elegantly balances the definition of possible errors within a given scope while remaining succinct and developer-friendly.

Here's a sneak peek of how it looks: rust error_set! { MediaError = { IoError(std::io::Error) } || BookParsingError || DownloadError || ParseUploadError; BookParsingError = { MissingBookDescription, CouldNotReadBook(std::io::Error), } || BookSectionParsingError; BookSectionParsingError = { MissingName, NoContents, }; DownloadError = { InvalidUrl, CouldNotSaveBook(std::io::Error), }; ParseUploadError = { MaximumUploadSizeReached, TimedOut, AuthenticationFailed, }; }

With error_set, we no longer need "god enums" that are used in scopes where some variants can never happen. Instead we can tersely define the errors in scope and coerce them into a superset if propagated up the call stack..

I've successfully integrated error_set into a project of mine, and I'm excited to see how it can benefit the broader Rust community. If you find it valuable, consider giving a star!

Github:

19
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/ivanceras on 2024-04-08 10:47:33.


Lately an update in ubuntu 23.10 for some reason makes my gnome-terminal becomes sluggish and visibly slow to respond to keystrokes, compared to before the updates. I liked gnome-terminal because I open a lot of nvim instances for each rust project and I could just easily Alt+1..9 on my tabs. I have tried alacritty before but I ended up opening too many windows, since it has no tab supports yet. It becomes harder to keep track which window is which project. I then tried tmux, but it seems I have too much keys to pressed and it's hard to memorize and keep track of new key combinations. Then comes zellij, With zellij, I don't need to memorize because the keys to pressed is always visible and intuitive. I then configured my ~/.config/alacritty.toml to use fish shell and open zellij everytime I open a new instance. Here is my only configuration to alacritty.toml

[shell]
program = "/bin/fish"
args = ["-l", "-c", "zellij"]

[font]
size = 10

So, now I don't need to open multiple alacritty instance since panes and tabs will do just fine.

Maybe next step is to use helix for nvim. A big thank you to the developers of Alacritty, Zellij, fish for making performant tools.

20
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/orhunp on 2024-04-08 13:37:35.

21
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/seashell-signal on 2024-04-08 08:27:45.


Hello, r/rust, I created rust-dex.cc, a website that provides bite-sized readable and straight-to-the-point breakdown of standard rust traits [1]

I got the idea for building this when I noticed that I found a lot of great insights in often very hard to find places and at times these instances were singular occurrences that would not be reiterated again (or can be very hard to find corroboration for), and so I started making the site, and eventually this is what it ended up being.

The traits are explained in first person, via two perspectives: first, the perspective of an implementor of the trait, and second, the perspective of the trait itself. I personally found this to be useful because it skips some of the mental re-orientations that's sometimes needed when you're reading the trait signature and documentation.

  • the site is unfortunately not mobile friendly right now.

some points about the site:

  • The website is entirely local (its a react SPA with no backend), so you can browse each of the trait entries offline.
  • Every trait comes with a comment-heavy code snippet that explains the trait and how it functions and the results of its implementation for a random type.
  • The source for all traits covered in the site is available in a single json on ()
  • You can search for traits any where on the site using CTRL-F to switch quickly between one trait and another
  • I will continue to update every traits whenever something comes up, with the goal of eventually having every trait in there (and having a better frontend).

[1] as of right now - nightly traits are excluded, and a couple of the std modules.

I tried to go for pokedex-like presentation but couldn't spend much time on the visuals so right now the site might not have the best looking frontend.

22
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/WellMakeItSomehow on 2024-04-08 08:26:45.

23
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/Sib3rian on 2024-04-08 08:17:16.


Let's say I'm working on a hobby web app, so I keep things simple and go with SQLite; more specifically, the wonderful rusqlite crate. The app released and works well, so it takes off, but as my user base grows, I realize I could benefit by switching to a client-server database.

However, rusqlite is synchronous. Even if I abstracted database access with something like the repository pattern, I've committed to synchronous Rust. Moving to, say, Postgres means I've got to mark every function that calls into the database async and adjust the functions that call those—my domain layer—accordingly. It's a leaky abstraction. The domain layer should not care in what manner the data is retrieved.

Furthermore, if I initially went with a synchronous web server, I would need to rewrite my entire web layer. Ideally, web frameworks would let us describe the what of our app—the routes, the extractors, the middleware—and be generic over the how.

Is that possible? I realize there's a lot of complexity hiding inside asynchronous Rust, but I don't understand it well enough to say if it's accidental or essential in respect to the higher-level apps that use it.

If it's not doable today, could it be in the future? Asynchronous Rust is, after all, only half-complete. Have other languages—perhaps in the functional family—solved this problem, and could Rust learn from them?

24
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/krabsticks64 on 2024-04-08 03:52:46.


Hello! I was wondering, if I have a method like:

pub fn with_field(mut self, value: u32) -> Self {
    self.field = value;
    self
}

would rust always be able to optimize it? or would it sometimes be copied? (assuming we're compiling with optimizations, and the type is sufficiently big, such that copying it is non trivial).

25
 
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/philip_dye on 2024-04-08 01:06:30.


If it is just these two open issues, then I would be happy to work on them.

  • Add a test confirming that it's an ExprWithBlock, so works in a match arm without a comma
  • Address issues with type inference (try { expr? }? currently requires an explicit type annotation somewhere).

Or are there other political/acceptance issues that have left this hanging for the last several years?

Thanks

view more: next ›