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.

Filter by
Sorted by
Tagged with
4 votes
3 answers
318 views

Not long ago while I was exploring for solutions to test without mocks I've found out about the functional core, imperative shell architecture. It sounds great, I also think that it would play nicely ...
 sentientbottleofwine's user avatar
12 votes
4 answers
3k views

In our current architecture, we have a React frontend communicating with a Rust backend via REST calls. We are considering introducing a PostgreSQL database, and my colleague suggests that we should ...
user avatar
2 votes
3 answers
320 views

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
4 votes
4 answers
375 views

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
0 votes
2 answers
347 views

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
0 votes
0 answers
107 views

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
  • 139
1 vote
1 answer
242 views

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
0 votes
2 answers
1k views

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
  • 374
0 votes
2 answers
107 views

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
0 votes
3 answers
199 views

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
  • 9
1 vote
0 answers
166 views

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
  • 119
0 votes
2 answers
125 views

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
1 vote
0 answers
148 views

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
  • 119
27 votes
6 answers
28k views

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
  • 403
2 votes
1 answer
673 views

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
  • 29
-2 votes
1 answer
90 views

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
  • 1
2 votes
1 answer
2k views

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
  • 139
0 votes
1 answer
91 views

I am trying to build a file editor, and I wanted to build the UI using Flutter. However I wanted to implement IO operations (reading a file, applying changes, etc) in Rust. The reason I would like to ...
Fabrizio's user avatar
  • 115
1 vote
1 answer
362 views

I have a little bit of experience with Go, that I have been trying to use as a reference point to wrap my mind around Rust via a cards game I wrote in Go that I would like to now write in Rust. I know ...
Daniel's user avatar
  • 119
5 votes
1 answer
576 views

In the code snippet found in this tweet, pattern matching is used like this: let (|x| x) = |_| Some(1); // same as `let (x | x) = |_| Some(1);` Which threw me off. Rust's pattern syntax is defined as:...
Calo's user avatar
  • 63
-2 votes
1 answer
166 views

A social network has API, but also it has some limitations like the amount of requests that can be done in one second (let's say API will give an error, if it accepts more than 3 requests per second) ...
Roy King's user avatar
1 vote
2 answers
366 views

I'm learning rust and curious to know the purpose that we can allocate memory sizes to data types. I'm not clear yet how this could be an advantage. It can definitely save up some memory space but I ...
Lionel's user avatar
  • 19
4 votes
5 answers
2k views

I was reading about composition over inheritance and came across a question about solving the Circle-Ellipse Problem in Object-Oriented Programming. This kind of problem is often used as an example of ...
drkvogel's user avatar
  • 157
2 votes
1 answer
3k views

Coming from the world of C#, where, despite sharing namespaces, it's quite common for every class to have its own file, I find that Rust codebases seem to have a complete different sort of philosophy (...
Brian Reading's user avatar
4 votes
1 answer
568 views

Let's take at random a well-written piece of Rust code: let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { label: Some("Shader"), flags: wgpu::ShaderFlags::...
Zomagk's user avatar
  • 261
2 votes
1 answer
156 views

I am modeling a ship that has contracts. Each contract can either be a fixed rate contract which pays a set fixed amount every day or a market index contract which pays an amount that varies based on ...
cpage's user avatar
  • 57
67 votes
9 answers
9k views

Java has "checked exceptions", which force the caller of the method to either handle an exception or to rethrow it, e.g. // requires ParseException to be handled or rethrown int i = ...
Heinzi's user avatar
  • 9,868
2 votes
1 answer
495 views

Warning: long question ahead, don't be afraid, I just tried to be as precise as possible about details for who wants them but many paragraphs are skipables if you already understood what I want ;). ...
jthulhu's user avatar
  • 141
3 votes
1 answer
3k views

this is my first post on here, and I'm wondering about a good rust implementation with traits on enum types. I want to know if using an enum w/ a trait as a generator of different code is viable like ...
Truffle's user avatar
  • 39
4 votes
1 answer
4k views

I'm looking for a way to manage constant strings in a Rust project. The hope is to manage my strings from a single file and avoid having the same string literals all over the place in the project. ...
temarsden's user avatar
  • 149
10 votes
1 answer
452 views

Tiled images Tiled images are large images that have been split in smaller square tiles. There are several tiled image formats, with different ways of organizing the tile files. A tiled image on ...
lovasoa's user avatar
  • 209
3 votes
2 answers
3k views

I recently read an interesting Article that, due to a memory Overflow error Power system of Boeing will collapse and turns the Flight into a Flying Brick. This is a low level memory Handling bug. ...
Avinash's user avatar
  • 141
5 votes
3 answers
542 views

In Rust, Send (or Sync) marker traits are used to indicate whether a value of a type (or a reference to that) can be worked on within threaded context. However, it is an attribute of a function or a ...
Amin Sameti's user avatar
1 vote
1 answer
246 views

I'w writing a program in Rust that basically pushes data through a pipeline of steps that transforms it in different ways. The data is represented by an Entry, and I am designing a Step trait for the ...
Anders's user avatar
  • 1,361
10 votes
5 answers
850 views

I've been thinking a lot lately about safe code. Thread-safe. Memory-safe. Not-going-to-explode-in-your-face-with-a-segfault safe. But for the sake of clarity in the question, let's use Rust's safety ...
TheEnvironmentalist's user avatar
7 votes
0 answers
427 views

In the Rust documentation, under the structs section, they give this example of how structs need lifetimes when they contain references: struct Foo<'a> { x: &'a i32, } because We need ...
user avatar
4 votes
1 answer
658 views

Rust is advertised as a "concurrent" language, what does this mean specifically and how is it different from other languages such as C++?
Greg's user avatar
  • 153
2 votes
1 answer
131 views

I have to perform a number of 'housekeeping' tasks that need root access (Linux, Debian). Generally one time only, but I do need to check that they have been performed. I don't really want to run the ...
tl8's user avatar
  • 131
-2 votes
1 answer
360 views

I have a piece of code. struct HasName { name: &'static str } trait CanGreet { fn greet(&self); } impl CanGreet for HasName { fn greet(&self) { println!("Hello {}", ...
Tristan's user avatar
  • 21
4 votes
1 answer
721 views

I am using Rust 1.15.1 and, recently, I stumbled over a problem I could not find a straight forward solution for. When you look at examples using pattern matching they usually destructure the object ...
Jonny Dee's user avatar
  • 947
8 votes
2 answers
754 views

I recently I started learning Rust and Scala and what struck me was the lack of inheritance model that I'm used to in C++ and Java. Although I can model simple things with structs and traits in Rust,...
sadiq.ali's user avatar
  • 217
6 votes
1 answer
2k views

Rust needs external linkers (e.g. GCC) to generate final output. Why doesn't it provide a bundled one? Are there any languages that does the similar?
Frederick Zhang's user avatar
6 votes
1 answer
465 views

I'm writing a compiler that compiles to C, one thing I'm attempting to do is implement a construct like Rust's match: // { some function let mut foo = 32; match foo { 3 => return "...
Jon Flow's user avatar
  • 383
19 votes
1 answer
2k views

Looking through this article on Rust's concurrency safety: http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html I was wondering how many of these ideas can be achieved in C++11 (or newer)....
Brannon's user avatar
  • 371
40 votes
2 answers
4k views

Questions I am trying to understand whether Rust fundamentally and sufficiently improves upon the concurrency facilities of C++ so that to decide if I should spend the time to learn Rust. ...
thb's user avatar
  • 757
28 votes
8 answers
6k views

I know this is a very broad, ambiguous, and possibly philosophical question. To an extent, that the most important keyword in the question - "strong" type system - itself, is ill-defined. So, let me ...
Saurabh Nanda's user avatar
7 votes
1 answer
566 views

I am currently writing an API for machine learning algorithms in Rust and I would like for a single genetic algorithm, artificial neural network, or Bayesian network to provide multiple outputs so ...
vadix's user avatar
  • 81
4 votes
1 answer
4k views

In the Importing External Crates section of the Rust book the author creates main.rs file in an already existing library project. I randomly picked up a bunch of crates from crates.io, examined their ...
Sergey's user avatar
  • 263
11 votes
2 answers
4k views

I've been reading some articles on how Rust does error handling using the Result<T, E> type and to me it seems like a hybrid best-of-both-worlds (exceptions and return codes) solution which can ...
stijn's user avatar
  • 4,168
0 votes
2 answers
129 views

I'm trying to write a generic function summ in rust - but to no avail. Could someone please elucidate the problem? fn summ<T:Add>(a:T,b:T)->T { a+b }
tyro1's user avatar
  • 23