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

Is this enum/trait a good way to implement polymorphic design in Rust?

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 ...
-6
votes
0answers
88 views

What is Rust's excuse for not having proper classes? [closed]

Why doesn't Rust have proper classes? What's the end-game here?
2
votes
1answer
160 views

Managing const strings in a Rust project

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. ...
8
votes
1answer
223 views

How to design a good generic tiled image downloader?

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

Can Rust replace the C or C++ programs in the Future? [closed]

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. ...
4
votes
3answers
289 views

Why datatypes are marked as thread-safe instead of procedures?

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 ...
1
vote
1answer
137 views

Signature for a Rust method that modifies object but might also drop it?

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 ...
10
votes
5answers
631 views

Is it possible to programmatically evaluate safety for arbitrary code?

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 ...
5
votes
0answers
235 views

Rust and lifetime elision rules for structs?

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 ...
3
votes
1answer
395 views

In what ways is Rust a “concurrent” language?

Rust is advertised as a "concurrent" language, what does this mean specifically and how is it different from other languages such as C++?
2
votes
1answer
94 views

Section of program needs root access

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 ...
-3
votes
1answer
290 views

Rust and composition [closed]

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 {}", ...
3
votes
1answer
358 views

Can an object be moved through a match expression? [closed]

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 ...
7
votes
1answer
533 views

Comparision of modeling with inheritance vs idiomatic trait based composition

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,...
3
votes
1answer
766 views

Why does Rust require external linkers? Any other similar languages?

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?
5
votes
1answer
147 views

Implementing a construct like Rusts `match` in C?

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 "...
16
votes
1answer
854 views

possible to achieve Rust's ownership model with a generic C++ wrapper?

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)....
36
votes
2answers
3k views

How does Rust diverge from the concurrency facilities of C++?

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. ...
29
votes
8answers
6k views

Using a “strong” type system in the real world, say, for large-scale web-apps?

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 ...
6
votes
1answer
453 views

What is the most generic way to provide a variable amount of outputs from a Rust function?

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 ...
5
votes
1answer
3k views

Publishing a crate containing both lib.rs and main.rs files

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 ...
8
votes
2answers
2k views

Rust-style error handling in C++

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

problems compiling a function with a trait Add in Rust [closed]

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 }
69
votes
1answer
16k views

How are Rust Traits different from Go Interfaces?

I am relatively familiar with Go, having written a number of small programs in it. Rust, of course, I am less familiar with but keeping an eye on. Having recently read http://yager.io/programming/go....