Rust

7718 readers
35 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 2 years ago
MODERATORS
226
11
submitted 9 months ago* (last edited 9 months ago) by catch22@programming.dev to c/rust@programming.dev
 
 

Hello, I'm fairly new to Rust and came across this. Can someone explain to me how the following example is able to infer the constant value from the array length passed in? At this point, inferred type generation for function calls are a bit hand wavy, to me, does anyone know of a resource that breaks down all the different ways they can be used (for instance in this example I hadn't seen them used for consts) and what their limitations are in Rust? I often run across a 'this type can not be inferred' error without really knowing why not and just throw in the type to make it go away.

Any other examples people could point me to would be appreciated as well.

Thanks!

#[derive(Debug)]
struct Buffer<T, const LENGTH: usize> {
    buf: [T; LENGTH],
}

impl<T, const LENGTH: usize> From<[T; LENGTH]> for Buffer<T, LENGTH> {
    fn from(buf: [T; LENGTH]) -> Self {
        Buffer { buf }
    }
}

fn main() {
    let buf = Buffer::from([0, 1, 2, 3,5]);
    dbg!(&buf);
}

Edit: for some reason, the code markdown is hiding things inside of the <>'s (at least on my lemmy viewing client)

227
 
 

Hey all, just looking for some advice. I'd like to do a WASM application, just generally like a calendar + notes app. I'd like it to work on mobile and desktop through the browser. It'll be served through Actix with Diesel for the backend. For the "frontend" I was thinking egui or leptos.

I'd like to avoid any JavaScript, so thought SSR might be the best approach.

Any thoughts/pitfalls? Should I look at something else for the frontend?

Its a lot of working parts for a calendar + notes app, but this will be a testing ground to see if I can get it all going :S

228
229
230
26
Announcing rustup 1.28.2 (blog.rust-lang.org)
submitted 9 months ago by neme@lemm.ee to c/rust@programming.dev
231
40
submitted 9 months ago* (last edited 9 months ago) by BitsandBytes@lemmy.world to c/rust@programming.dev
 
 

Hi there Rustians! A few months ago I posted about my hobby project. Just wanted to give an update.

Axium is a template for an API backend.

In the last few months I have added:

  • HTTP-cookie authentication (got it to work with a javascript site),
  • Password resetting,
  • User registration,
  • Example routes for interacting with S3 storage
  • Lots of input validation,
  • Caching,
  • Mailing (for the password reset and user registration).

I think that it is almost ready to be used as a backend for my website. Almost everything is marked off my wishlist, just need a few helper to help me check the security of the authentication and registration functions.

GitHub: https://github.com/Riktastic/Axium

232
 
 

This article delves into various techniques for reclaiming disk space from Cargo build artifacts.

233
48
Bevy 0.16 (bevyengine.org)
submitted 9 months ago by Phlimy@jlai.lu to c/rust@programming.dev
234
 
 

Kellnr, the registry to self host crates, has a new UI. I rewrote it to make it more consistent and responsive. Give it a try, if you want to host crates on your own infrastructure. https://kellnr.io/

235
 
 

Instead of emitting one giant crate containing everything, we tweaked our SQL-to-Rust compiler to split the output into many smaller crates. Each one encapsulating just a portion of the logic, neatly depending on each other, with a single top-level main crate pulling them all in.

236
237
238
 
 

I just released helper library for deku to decode and encode strings in popular binary layouts (fixed length, pascal-like and c-like)

https://crates.io/crates/deku_string

239
 
 

I made a small project using leptos, but after updating leptos ended up with some unfixable bugs. The error and warning messages are too inaccurate, and due to all reactivity being implicit, it is hard to read my code now and figure out what would be wrong.

I thought about rewriting everything in yew, but was wondering if things work better there. As far as I understand, there is no such thing as implicit reactivity in yew, and everything that needs to be reactive needs to be wrapped in certain types. But I am fine with that, even though #[derive(Store)] in leptos was convenient.

Does anyone use leptos or yew in production or for any more serious projects, and can share some experiences? How do you usually debug your applications? Have you given up on some application that just didn't work?

240
241
 
 

I've been pretty busy in my life recently, but I finally got around writing this blog post. Hopefully, things are sorted out in my personal life and I should be able to be more regular about these updates in the future.

I'm very happy to see good progress towards rustup distribution (thanks to Kobzol again!).

242
243
244
4
submitted 10 months ago* (last edited 10 months ago) by neme@lemm.ee to c/rust@programming.dev
245
5
submitted 10 months ago* (last edited 10 months ago) by MITM0@lemmy.world to c/rust@programming.dev
 
 

Ok so I am currently using FLTK-rs for GUI design so if there's an fellow rustacean I would like your input.

Am I making any progress in this project I have undertaken (I advise you navigate to the Files section/tab). I need some feedback

I am using FLUID to build the GUI & basically I wish to recreate LBRY-Desktop. Please do note that, I come from a non-programming background.

246
60
Announcing Rust 1.86.0 (blog.rust-lang.org)
submitted 10 months ago by neme@lemm.ee to c/rust@programming.dev
247
12
submitted 10 months ago* (last edited 10 months ago) by absolutely_vivid@programming.dev to c/rust@programming.dev
 
 

I built a library for working with a compression format used by Godot. It’s my first Rust library and I thought the little bit of reverse engineering I did for the format would make for an interesting blog post. Let me know what you think!

(Reposting because I still don't know understand the lemmy UI lol)

248
 
 

Typst, a very nice Latex alternative, written in rust has published job listings.

249
 
 

We're very happy to announce the first release of Ariel OS, an embedded Rust library OS. Ariel OS runs on small MCUs like nRF5x, RP2xxx, STM32 and ESP32. It is based on Embassy, and turns that into a full-blown RTOS, with preemptive multi-core scheduling and many OS-like conveniences.

We believe it offers a new combination of features that might be interesting:

  • It supports writing applications as both async and threaded code, mix-and-match.
  • It helps a lot in reducing boilerplate. Networking, threads & multi-core suppport, random numbers, flash storage are all readily available, with a sane and usually customizable default configuration.
  • It helps writing portable applications. Ariel applications start out being fully ported to all supported boards, then get specialized. This might be interesting to library authors as well, for simplified testing on multiple platforms.
  • It helps handling the little differences between MCUs. E.g, rustc target configuration, using defmt or not, probe-rs or esp-flash, are just build system flags. Ariel OS' meta build system handles the necessary Cargo and tooling configuration.
  • It integrates embedded-test for turn-key testing on real hardware.
  • It's all Embassy & smoltcp & embedded-hal(-async) & embedded-nal(-async) & ... under the hood, and it is easy to not use the abstractions if needed.

What we're working on right now or very soon:

  • building on stable Rust
  • BLE support
  • a nice DSL for defining boards, aiming at no-code porting of applications
  • low power handling
  • a native "port" where Ariel can run as Linux/OSX application

We're at the beginning, but think that Ariel OS might already be useful to many of you, especially for reducing boiler plate and getting started more quickly.

Let us know what you think!

Join us on Matrix in #ariel-os:matrix.org.

250
view more: ‹ prev next ›