Skip to main content

Questions tagged [rust]

Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It maintains these goals without needing a garbage collector, making it a useful language for a number of use cases other languages aren't good at: embedding in other languages, programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems.

2votes
3answers
210views

Aggregate with a huge list of value objects

I'm currently reading "Implementing Domain-Driven Design" while going through the code samples, but I'm having trouble modeling aggregates that stores a huge list of value objects. For ...
Kyle Richards's user avatar
3votes
4answers
238views

Is it reasonable to ignore const functions in Rust and treat them as a premature optimisation?

While I'm far from an expert at Rust, I'm becoming a proficient Rust user; I've written a substantial Rust library that is now being used in production. While I understand what const fns are, I haven'...
curiousdannii's user avatar
0votes
2answers
220views

Intuition behind why Rust's io::stdin().read_line() relies on a side effect?

I'm reading the second chapter of the official Rust book as a pretty seasoned python programmer. As you can imagine, its been pretty jarring, but I'm learning. My specific question is about whether or ...
Ryan Folks's user avatar
0votes
0answers
90views

Is it really difficult to test these “Service” methods in this Rust Clean Architecture proposal? Is there some other catch I'm not considering?

I reproduced a small example of kerkour's Rust Clean Architecture on the Rust Playground. The code is just an example and the methods code makes no sense at all. This architecture leaks DB information ...
Fred Hors's user avatar
1vote
1answer
201views

How difficult would it be to extend Rust's compile time checking to dynamic linking?

When compiling Rust, various additional checks are made for correctness. These include bounds checking, borrow checking for multithreading and memory ownership, and the like. Once compiled, these ...
John Moser's user avatar
0votes
2answers
862views

What problem does Rust's "atomic reference count" actually solve?

The Rust programming language offers a Arc atomic reference counting generic type for use in multi-threading environment, since Rc is optimized for performance in single-threaded applications, and ...
DannyNiu's user avatar
0votes
2answers
86views

Deserializing serial protocol enums: Recoverable or unrecoverable errors?

I am currently implementing a library in Rust that implements a proprietary serial protocol. The protocol specifies several enum values, that mostly are returned by the hardware as u8s (bytes), but ...
Richard Neumann's user avatar
0votes
3answers
166views

Is there a distinct optional type semantically representing a value that *needs to be calculated later*?

Semantically, C++ std::optional, Rust Option<T>, and other optional/nullable types represent a value that can be present or absent: you have to handle both cases, or you can opt-in to crash. Is ...
JJW's user avatar
1vote
0answers
134views

How can I represent a transformed AST between compilation stages?

I'm writing a compiler in Rust. I've reached the point where I have an AST and am ready to do symbol resolution, type-checking, etc. But, I'm unsure of how to represent an AST as containing "...
gmdev's user avatar
0votes
2answers
109views

What are the pros and cons of structuring an application as a pipeline of functions mutating a shared struct?

I could not find anything regarding this question except some lecture notes about game design and a book which describes something similar but not quite the same. General Description The approach is ...
laggyfrog's user avatar
1vote
0answers
129views

Designing an API adapter with multiple authentication types

I'm building an HTTP API database adapter that has an authentication component. Users can authenticate using password, federated login such as OAUTH, and JWT. My initial design is something like the ...
seve's user avatar
26votes
6answers
24kviews

How can Rust be "safer" and "faster" than C++ at the same time?

I have been told that Rust is both safer and faster than C++. If that is true, how can that be even possible? I mean, a safer language means that more code is written inside the compiler, right? More ...
euraad's user avatar
2votes
1answer
595views

Representing Rust enums in databases

Although I love Rust's enums (and the idea of making illegal states unrepresentable), I'm struggling to represent (ironic, yes) them in databases like PostgreSQL when the variants have data associated ...
yoshke's user avatar
-2votes
1answer
84views

How would data be dynamically queried in rust

Say there is an user that wants to query a random element during runtime from a dynamic struct. The type of the data is unknown, but all the data is either a integer (size unknown), float, string, or ...
Star's user avatar
2votes
1answer
2kviews

Build a Rust project using Clean architecture and DB transactions in the same DDD bounded context

This is just an example of an (still incomplete) real-world project written in Rust using a clean architecture: https://github.com/frederikhors/rust-clean-architecture-with-db-transactions. Goals My ...
Fred Hors's user avatar

153050per page
close