Most voted "rust" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to the Rust programming language.
Learn more…26 questions
Sort by count of
-
23
votes2
answers3224
viewsWhat is the Rust programming language?
According to the official page of language: Rust is a system programming language that runs incredibly fast, prevents segmentation failures, and ensures cross-threaded security. It is relatively…
-
13
votes1
answer286
viewsWhat are Zero Cost Abstractions?
I was reading about Rust and I saw that one of its advantages is to own Zero Cost Abstractions, I would like to know: What are Zero Cost Abstractions? It is something that the programmer needs to…
-
9
votes1
answer191
viewsWhat is Borrow Checker?
I was reading a little bit about Rust and I came across that term, I’d like to know: What is Borrow Checker? Is there any connection with Counting? What would be the translation for this term in…
terminology characteristic-language garbage-collector rustasked 4 years, 9 months ago Denis Rudnei de Souza 3,686 -
8
votes1
answer132
viewsIn Rust how does ampersand and asterisk work?
I came from Java recently and I’m studying Rust. Language has a totally different paradigm than I was used to, but it caught my attention. For never having messed with C or C++, sometimes I find…
-
8
votes1
answer141
viewsWhat are the differences between "String" and "str" in Rust?
I know there are (apparently) two main types of string in Rust: str, which, as far as I can tell, is a primitive type; String, which, as far as I know, is part of the standard library std of…
-
7
votes1
answer86
viewsHow does async/await work in Rust?
The idea of async/await has become common in several languages (C#, Javascript etc). It seems that Rust recently (in the 2018 edition of Rust) adopted the idea of async/await, together with the…
-
6
votes2
answers1288
viewsWhat do "re:" and "im:" mean in Rust?
I want to know what re and im mean/do let mut z = Complex { re: 0.0, im: 0,0 }; I’m learning Rust by the book Programming Rust and this re: and im: it must have appeared before, but only now have I…
-
6
votes1
answer107
viewsWhat are the advantages and disadvantages of encapsulated errors types like "Result"?
I’m learning Rust and one of the things that made me curious is the absence of exceptions. Unlike languages such as C#, Java, Javascript, etc., which have exceptions, in Rust this does not exist. If…
-
6
votes1
answer85
viewsWhat’s the difference between mod and Rust?
I understand the workings of the keyword mod, explained in this matter. For users of Python, mod works exactly like the keyword import. That is, to use functions and other objects defined in a file…
-
5
votes1
answer53
viewsWhat good is lib.rs in Rust?
As shown in this question, in Rust it is possible to import a file (its structs, functions, etc) using the keyword mod. For example, in the following directory structure: src/ main.rs…
-
5
votes1
answer44
viewsHow to use Result in user-defined function?
Many Rust functions apply the enumerable Result in its implementation. This enumerable makes it easy to manage error, since you can use unwrap or expect to help identify the error in a code. An…
-
5
votes1
answer35
viewsComparing captured keyboard strings to Rust
I’m trying to learn Rust and naturally I’m starting with "The Book". At the end of chapter 3 has 3 simple logic exercises, and one of them is the classic converter from Fahrenheit to Celcius. I…
-
4
votes1
answer100
viewsWhat is Monomorphization?
I was reading that posting and I came across that term monomorphization I’d like to know: What is its meaning? When this process occurs? What performance gain/loss is obtained by this process?…
-
4
votes1
answer124
viewsWhat does the "value used here after move" error mean in Rust?
I am studying Rust and would like to better understand when I can and when I can’t use the same variable more than once in the same scope. I leave below two examples. In the first, the program works…
-
4
votes1
answer74
viewsWhat is Clone-on-write (Cow)?
I’m studying Rust and recently discovered the existence of Cow, one smart-Pointer that works to make Clone-on-write. The description of the page seemed confusing to me, since I don’t have much…
-
4
votes1
answer56
viewsWhat are the differences between Traits (or Typeclasses) and Interfaces?
Studying Rust, I began to make use of the so-called traits that, according to the language book: We can use traits to define shared behavior in an abstract way. The same chapter further quotes the…
-
4
votes1
answer123
viewsWhat is the difference between the rest operator (%) in Python and Rust?
Writing a small program in Rust, I noticed that the operator results % are different from what I get in Python for negative numbers. For example, in Python -4 % 26 returns 22, but in Rust: fn main()…
-
3
votes2
answers93
viewsHow to correctly iterate all records of a structure with multiple depth levels in Rust?
I would like to know how to iterate correctly in Rust all the results contained in a data structure so arranged: struct Node { id: i64, nodes: Vec<Node> } Where records entered in this…
-
3
votes1
answer48
viewsWhat is the point of using Option as a type in the argument of a function?
I’m trying to use a function that has as argument a variable of type Option. An example without Option: fn main() { next10(9); } fn next10(n: i32) { for i in n..n+10 { println!("{}", i) } } An…
-
3
votes2
answers144
viewsWhat are the differences between constants declared with const and immutable variables declared with Let in Rust?
The declaration of immutable variables In Rust if you want to declare a variable, we use the keyword let. Example: fn main() { let site_name = "Stack Overflow em Português";…
-
2
votes3
answers237
viewsModules in Rust
The structure of my project is like this: src/main.rs --- game.rs --- game_state.rs Within game.rs has: mod game_state; And within game_state.rs has mod game; But this returns me an error: file not…
-
2
votes1
answer111
viewsRust difference between Std::ops for normal operators
Hello I am seeking to optimize mathematical operations in my program, exploring the modules of the Rust found the Std:. My question is this:. use std::ops::{Add}; fn main() { let x = 10;…
-
1
votes1
answer179
viewsHow to search for a substring from an offset in Rust?
How to find the index of the beginning of a substring starting from a given index of string? In C++, for example, the method std::string::find accepts a offset or index where the search should…
-
0
votes2
answers101
viewsRust installation error in windows 10
I am taking my first steps in the language. I have read much of the documentation and decided to install it on my machine. I lowered the rustup-init here. However, when I run the installer I have…
rustasked 6 years, 10 months ago Fernando Paz 158 -
0
votes1
answer28
viewserror: Linker`cc` not found when trying to compile file . rs
I am trying to compile a file. Rust via vscode terminal, and I get this error: causticroot@install:~/learning-rust/Book exercises/Hello world> rustc hello_world.rs error: linker `cc` not found |…
-
0
votes0
answers45
viewsHow to extract pdf string in Rust?
I’m trying to use the package pdf_extract to manipulate pdfs in Rust. I would like to extract the string from the pdf. I saw that the function for this is set so: pub fn extract_text<P:…