451
25
submitted 2 years ago* (last edited 2 years ago) by onlinepersona@programming.dev to c/rust@programming.dev

I've got 64 GB of RAM and would like to force cargo to dump build artifacts into it. So basically the target/ directory should end up there.

Unless I'm mistaken RAM is much faster than SSDs and since I do rebuild quite often, it would save some R/W cycles on my SSD and allow faster file access.

I do jot mind doing a full rebuild every morning

Solution:

These 2 comments gave me the best indication how to do it: cargo ramdisk and build.target-dir config options.

Would be great if cargo had a build.target-dir-prefix though. One could set and env var CARGO_TARGET_DIR_PREFIX and point it at /dev/shm or /tmp if it's a tmpfs and every rust project would have its artefacts end up in RAM.

452
41
453
15
454
15

Jiff is a datetime library for Rust that encourages you to jump into the pit of success. The focus of this library is providing high level datetime primitives that are difficult to misuse and have reasonable performance.

And as a user of Jiff, I must say that it is very nice to use. Well thought out API, making date time handling less of a pain. So, nice work @burntsushi@programming.dev

455
7
456
19
457
29
crates.io: development update (blog.rust-lang.org)
458
19
submitted 2 years ago* (last edited 2 years ago) by jasory@programming.dev to c/rust@programming.dev

I wrote up a port of GNU factor that has a slightly nicer UI than the original, and runs in approximately 1/3rd the time for 128-bit integers, on average. This is just a preliminary release and I plan implementing elliptic curve arithmetic and extending it to 192-bit to cover all the small integers that CADO-NFS doesn't support.

The factorization algorithm is provided as a separate crate that provides a C-api, since fast factorisation algorithms are hard to come-by.

459
22
submitted 2 years ago by cm0002@lemmy.world to c/rust@programming.dev
460
34
submitted 2 years ago by kionite231@lemmy.ca to c/rust@programming.dev

Greetings,

sometimes I want to read new comments on a particular post but I don't want to check it every hour to see new comments. It would be nice if I can just say "!remind 5h" so that I get a reminder to checkout a specific post which would have new comments after 5 hour.

I am thinking about making it myself in Rust, but if there is already a bot here and I don't know, please tell me.

461
77
Announcing Rust 1.84.1 (blog.rust-lang.org)
submitted 2 years ago by neme@lemm.ee to c/rust@programming.dev
462
20
Terminal clock (github.com)
submitted 2 years ago by fil@programming.dev to c/rust@programming.dev

I've made a tui clock. Ratatui now is so nice to use compared to 1 year ago!

463
10
submitted 2 years ago by Aras@feddit.org to c/rust@programming.dev

Inspired by Contex-Generic Programming, I made this macro, that allows you to write those generic implementations easily. This is kinda CGP, but simple and with better errors.

Ever repeat yourself implementing traits? Or wanted to easily swap out parts of your code, with (almost) no need to refactor? That is what this is for.

464
28

yeehaw is a TUI framework with a full event routing system and plethora of built in elements.

Highlights:

  • Actual Neovim can be used as a text editor element (or any other editor set in the $EDITOR environment variable). Likewise, any other TUI that outputs to the terminal can be integrated into an element.
  • The color system includes an alpha channel for transparency. A color can also be set to gradients (position or time-based). Basically a yeehaw color can effectively be a neopet's rainbow paintbrush if you want it too.
  • Element ownership at a glance: TUI Elements are organized in a hierarchical manner while each retaining autonomy to change their ordering and position within their immediate parent. Events (keyboard/mouse/custom) are routed top down and responses propagate back upwards along the Element ownership tree. Simple elements are only normally required to have spatial awareness within the confines provided to them.
  • The core element Trait allows for customizable event/response types enabling developers to create entirely new sub-classes of elements which can reuse the event routing system.

This project is not yet entirely stable, however it felt necessary to unleash this monstrosity into the wild at this point. Feel free to ask any questions here or on github. Also this is my first rust release, so please forgive (and inform me of) missing idioms. -bogz

465
59
submitted 2 years ago by qaz@lemmy.world to c/rust@programming.dev
466
10
submitted 2 years ago* (last edited 2 years ago) by Doods@infosec.pub to c/rust@programming.dev

I shaved off 10 MiB from my binary in 2 hours!

I made a program using Macroquad, then I built it in release mode, the binary was 63 MiB in size.

So I used cargo vendor to have a better look at Macroquad and one of its dependencies, glam.

I then started to delete code, like, lots and lots of code(about 30_000 lines of code); none of it affected my main project, some of it became 'dead_code' just by removing the pub keyword.

The result is that my project was unaffected and the binary went down to 52 MiB.

Is there a way to automate removal of unneeded elements from dependencies? This is potentially huge.

EDIT: I FIGURED IT OUT!!!

My mistake was measuring the size of "target/release", I discovered that that folder contains many "unnecessary" files, like "deps", which greatly bloat the folder'r size, the actual size of my binary is 864K.

I am so relieved.

467
18
Rust Analyzer Changelog #269 (rust-analyzer.github.io)
468
19
469
13
submitted 2 years ago by DickFiasco@lemm.ee to c/rust@programming.dev
470
23

The fist new version of Kellnr in 2025 is released! If you want to self-host rust crates on your own infrastructure, check it out.

471
16

I've been coming back to the same project a few times. It's essentially just a program that interacts with an API. Only problem is whenever I get back to it, I realize how annoying it is to debug through all the "too many requests" responses I get back from the API because it has a max of 200 requests per second.

On solution would be to filter out those responses but that just feels like the wrong move, so I'm guessing the better solution would be to put some sort of rate limiter on my program. My two questions are: does that seem like a good solution and if it is, do I embed the rate limiter in my program, i.e. using the ratelimit crate or would a better solution be to run my program in a container and connect it to a reverse proxy(I think) container and control rate limiting from there?

472
22

This article very much conveys what I think.

473
8
submitted 2 years ago by dessalines@lemmy.ml to c/rust@programming.dev
474
45
submitted 2 years ago by kionite231@lemmy.ca to c/rust@programming.dev

What I learned about Rust while making pastebin in Rust

First iteration

Hello, I have recently started to make a pastebin to learn more about Rust and understand the underlying concept of Rust so I first made a very naive pastebin where I used axum to serve the files and used a TCPListener to handle file upload. I didn't use axum to handle file upload because I didn't know how to do it, so basically my program was listening to two different port 8080 and 3000 where on port 3000 I served the files and on 8080 I handle file upload using simple TCP connection. I also used a static variable to name the uploaded file, but in Rust mutable static variable considered unsafe since it could lead to race condition, but at that time I didn't know much about Atomic variables so I wraped the code with unsafe.

Second iteration

I uploaded my code of First iteration to Lemmy, and people on Lemmy gave me a lot of suggestions, like using Atomic variable to eliminate the need of unsafe block and using axum to handle file upload. so I implemented that.

Third iteration

there are still some security issue like anyone can scrape entire pastebin since I was using an incremental file name. also if I rerun the pastebin It will reset the file name variable and it would overwrite previously uploaded files, to overcome this issue a person on Lemmy suggested that I should use uuid, that way it would solve those security issue.

Final thoughts

so yeah, that was it, I learned a lot about Rust and programming in general, thank you all on the Lemmy to teach me these cool stuff :D

475
13

Logan Smith's Rust videos are excellent - I'm happy to see a new one is up!

view more: ‹ prev next ›

Rust

8252 readers
30 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS