Rust

6955 readers
16 users here now

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

Wormhole

[email protected]

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
1
13
April Project Goals Update (blog.rust-lang.org)
submitted 1 day ago by [email protected] to c/rust
2
3
 
 

I just learned the basics of macros and figured I'd give a shot trying to solve a problem I've had for a while. Theres just one derive trait in this crate, Variants, that when derived will generate a constant array that holds all of the enum's variants along with a method that exposes a static reference to the constant array.

Give it a look, leave some feedback, maybe even open up a PR. I hope you like what you see!

4
 
 

cross-posted from: https://lemmy.world/post/30361372

Hi all,

I don't know where would be the best place to post this, but I wanted some people's feedback on a DSL that I wrote for network analysis.

I am using nom for writing the lexer and parser, then using abi_stable crate for data types so that you can write plugins to the language and load them dynamically as well.

This language is made to work by loading a tree graph (network) and then call a bunch of node or network functions that work on it. There are different ways you can run functions, and use node/network attributes.

I am mostly self-taught, so it took a lot of years to get to a level where I could write something like this. I am learning a lot and having a lot of fun in the process, but I want this to develop into something that can have a practical usefulness to people. Since I am in the field of hydrology, I am making it with river networks in the mind.

To try it out, you can either download the executables for windows from the releases page, or you can compile it using cargo (for all OS; except android where GUI won't work, CLI will work in termux). I have some basic examples in the Learn By Examples section of the User Guide that you can follow.

Please let me know if you can't compile/use it as well. I have tried to make sure it has required instructions, but I could have missed something.

5
6
7
8
61
Oxidise Your Command Line (2025 Edition) (videos.abnormalbeings.space)
submitted 1 week ago by [email protected] to c/rust
9
16
This Week in Rust 600 (this-week-in-rust.org)
submitted 1 week ago by [email protected] to c/rust
10
11
12
13
8
This Week in Rust 599 (this-week-in-rust.org)
submitted 1 week ago by [email protected] to c/rust
14
 
 

Cross posting from https://programming.dev/post/30565644

Hi everyone,

yesterday, we released iceoryx2 v0.6, an ultra-low latency inter-process communication framework for Rust, C and C++. Python support is also on the horizon. The main new feature is Request-Response-Stream, but there’s much more.

If you are into robotics, embedded real-time systems (especially safety-critical), autonomous vehicles or just want to hack around, iceoryx2 is built with you in mind.

Check out our release announcement for more details: https://ekxide.io/blog/iceoryx2-0-6-release

And the link to the project: https://github.com/eclipse-iceoryx/iceoryx2

15
16
 
 

So I've had this idea for an API for a while but the problem I keep coming back to is authentication. I'm using rocket to actually code it. I looked through the rocket docs and it looks like the closest thing to API key authentication it has are cookies.

I then went and looked at some other APIs to see if I can copy their layouts and it looks like a lot of them use an API key and then a secret API key for authentication. Did some more googling and stackoverflow said that it's more secure to use a pair like that.

So that leaves me with the actual question: how do you actually implement this feature? Do you just generate API keys and throw them a database to be looked up later? Should they be written/read to a file to be used later(probably not a good option I'd guess).

Just for reference I'm using rocket, sqlx and postgres.

17
18
19
20
9
submitted 2 weeks ago* (last edited 2 weeks ago) by [email protected] to c/rust
 
 

Hello, I am starting to learn and play around with tokio and multithreaded code. I am now playing around with websockets, I don't quite understand the difference between broadcast and mpsc, and when would you use either, I mean, I am assuming broadcast is intended for multiple clients, but multiple clients were able to connect to my mscp channel, and receive a bit of data (but it was weird and partial). So I don't quite get it.

21
 
 

cross-posted from: https://programming.dev/post/30061235

As part of this expansion, Qt Group will introduce new bridging technology that integrates Qt with any programming language of choice, initially including Rust, Python, .NET, Swift, and Kotlin/Java.

I'd really like to use Qt for GUI and HMI development for certified medical devices using embedded hardware, but wasn't looking forward to all the conventional C++ that would have entailed. Looks using Rust with Qt may get better soon?

Second source reporting from Qt World Summit in Munich:

Part of the thinking here is that C++ is regarded as an unsafe language whereas the languages supported by Qt Bridges are safe languages, potentially escaping the notion that because Qt is C++, it is not as safe to use.

22
23
24
12
submitted 3 weeks ago* (last edited 3 weeks ago) by catch22 to c/rust
 
 

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)

25
18
Stack advice (self.rust)
submitted 3 weeks ago by Matty_r to c/rust
 
 

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

view more: next ›