Gang Of Coders
Home
About Us
Contact Us
All Rust Solutions on Gang of Coders
Total of 266 Rust Solutions
What are the differences between Rust's `String` and `str`?
String
Rust
Why doesn't println! work in Rust unit tests?
Rust
Println
How do I concatenate strings?
String
Rust
String Concatenation
How to disable unused code warnings in Rust?
Warnings
Compiler Warnings
Rust
Dead Code
Why does the Rust compiler not optimize code assuming that two mutable references cannot alias?
Rust
Reference
Compiler Optimization
Llvm Codegen
How do I print the type of a variable?
Types
Rust
What is the difference between iter and into_iter?
Rust
Convert a String to int?
Rust
How to match a String against string literals?
String
Match
Rust
Managing the lifetimes of garbage-collected objects
Garbage Collection
Rust
Allocation
Lifetime
Why can't I store a value and a reference to that value in the same struct?
Rust
Reference
Lifetime
Borrow Checker
Package with both a library and a binary?
Rust
Rust Cargo
What are Rust's exact auto-dereferencing rules?
Rust
Reference
Language Lawyer
How do I split a string in Rust?
Rust
Why are Rust executables so huge?
Rust
Rust Cargo
Why are explicit lifetimes needed in Rust?
Reference
Rust
Static Analysis
Lifetime
Why is there a large performance impact when looping over an array with 240 or more elements?
Arrays
Performance
Rust
Llvm Codegen
What is the syntax for a multiline string literal?
String
Rust
How do I create a global, mutable singleton?
Rust
How can I include a module from another file from the same project?
Rust
What's the de-facto way of reading and writing files in Rust 1.x?
File Io
Rust
How can a Rust program access metadata from its Cargo package?
Rust
Rust Cargo
What is the equivalent of the join operator over a vector of Strings?
String
Rust
What is the difference between traits in Rust and typeclasses in Haskell?
Haskell
Rust
Traits
Why is it discouraged to accept a reference to a String (&String), Vec (&Vec), or Box (&Box) as a function argument?
String
Reference
Rust
Borrowing
What is this question mark operator about?
Rust
How do I convert a Vector of bytes (u8) to a string?
Rust
What is the difference between Copy and Clone?
Rust
What is the correct way to return an Iterator (or any other trait)?
Rust
How can I build multiple binaries with Cargo?
Rust
Rust Cargo
When does a closure implement Fn, FnMut and FnOnce?
Rust
Closures
Default function arguments in Rust
Function
Parameters
Arguments
Rust
How can I access command line parameters in Rust?
Command Line
Rust
Is it possible to use global variables in Rust?
Global Variables
Rust
How does Rust's 128-bit integer `i128` work on a 64-bit system?
Rust
X86 64
Bigint
Int128
Llvm Codegen
How to use a local unpublished crate?
Rust
Rust Crates
Cannot move out of borrowed content / cannot move out of behind a shared reference
Reference
Rust
Move Semantics
Borrow Checker
When is it appropriate to use an associated type versus a generic type?
Types
Rust
Idioms
How to lookup from and insert into a HashMap efficiently?
Hashmap
Rust
Lookup
Is there a faster/shorter way to initialize variables in a Rust struct?
Rust
How do I iterate over a range with a custom step?
Rust
How to convert a String into a &'static str
Rust
How do I use a macro across module files?
Module
Rust
Rust Macros
What's the difference between use and extern?
Rust
What are the Rust types denoted with a single apostrophe?
Rust
How do I stop iteration and return an error when Iterator::map returns a Result::Err?
Rust
Rust Result
Idiomatic callbacks in Rust
Callback
Rust
No default toolchain configured after installing rustup
Rust
How do I convert from an integer to a string?
String
Int
Type Conversion
Rust
Cargo build hangs with " Blocking waiting for file lock on the registry index" after building parity from source
Rust
Rust Cargo
Split a module across several files
Module
Rust
Best way to concatenate vectors in Rust
Vector
Rust
Concatenation
How do you pass a Rust function as a parameter?
Rust
How do I fix the Rust error "linker 'cc' not found" for Debian on Windows 10?
Linux
Windows
Rust
What does 'let x = x' do in Rust?
Rust
How do I invoke a system command and capture its output?
Rust
How can I get the current time in milliseconds?
Rust
What does Rust have instead of a garbage collector?
Memory
Rust
Memory Management
What are non-lexical lifetimes?
Rust
Terminology
Lifetime
Lifetime Scoping
How do I create a HashMap literal?
Hashmap
Rust
What is a "fat pointer"?
Pointers
Rust
How can I update a value in a mutable HashMap?
Hashmap
Rust
Converting from Option<String> to Option<&str>
Rust
How do you iterate over a string by character
String
Iterator
Rust
Creating a vector of zeros for a specific size
Rust
How do I convert between numeric types safely and idiomatically?
Casting
Rust
Numbers
How to print a Vec?
Rust
Println
How to make a reverse ordered for loop?
For Loop
Rust
Why is capitalizing the first letter of a string so convoluted in Rust?
String
Rust
Uppercase
How to convert Vec<char> to a string
String
Rust
Unable to compile Rust hello world on Windows: linker link.exe not found
Compiler Errors
Installation
Rust
Linker Errors
Build Tools
What's the difference between placing "mut" before a variable name and after the ":"?
Variables
Syntax
Reference
Rust
Mutable
Step by step interactive debugger for Rust?
Debugging
Rust
Is it possible to write Quake's fast InvSqrt() function in Rust?
Rust
Floating Point
Sqrt
Type Punning
When should inline be used in Rust?
Rust
Inline
Llvm Codegen
Rust modules confusion when there is main.rs and lib.rs
Module
Rust
What's the difference between `usize` and `u32`?
Rust
Is there a command to update Cargo to the latest official release?
Rust
Package Managers
Rust Cargo
How to check release / debug builds using cfg in Rust?
Debugging
Rust
Preprocessor
Rust Cargo
How do I write a Rust unit test that ensures that a panic has occurred?
Unit Testing
Rust
What is a crate attribute and where do I add it?
Rust
Rust Cargo
What is the overhead of Rust's Option type?
Performance
Rust
Null Pointer
In Rust, is there a way to iterate through the values of an enum?
Enums
Iteration
Rust
How to create a Rust struct with string members?
String
Rust
How to sort a vector in Rust?
Rust
What's the difference between self and Self?
Rust
What is unwrap in Rust, and what is it used for?
Rust
Error Handling
What do I have to do to solve a "use of moved value" error?
Rust
How do I get the first character out of a string?
String
Rust
Benchmarking programs in Rust
Time
Benchmarking
Rust
How to get a slice as an array in Rust?
Arrays
Rust
How to index a String in Rust
String
Indexing
Rust
How do I find the index of an element in an array, vector or slice?
Rust
Is it possible to make a type only movable and not copyable?
Rust
How I can mutate a struct's field from a method?
Rust
Mutable
Converting a str to a &[u8]
String
Rust
Slice
Using map with Vectors
Rust
How does for<> syntax differ from a regular lifetime bound?
Rust
What is the idiomatic Rust way to copy/clone a vector in a parameterized function?
Rust
How to escape curly braces in a format string in Rust
String Formatting
Rust
How do I get a slice of a Vec<T> in Rust?
Vector
Rust
Why design a language with unique anonymous types?
C++
Types
Rust
Language Design
Does cargo install have an equivalent update command?
Rust
Rust Cargo
How to write a Rust function that takes an iterator?
Function
Iterator
Rust
How do I make an HTTP request from Rust?
Http
Rust
How do I convert a C string into a Rust string and back via FFI?
C
Ffi
Rust
What is the r#""# operator in Rust?
String
Rust
Syntax
String Literals
How to check whether a path exists?
Rust
What is monomorphisation with context to C++?
C++
Rust
Why does the println! function use an exclamation mark in Rust?
Rust
Is there any way to return a reference to a variable created in a function?
Reference
Rust
Lifetime
In Rust, what is the difference between clone() and to_owned()?
Rust
Is there a modulus (not remainder) function / operation?
Rust
Modulo
What is the difference between immutable and const variables in Rust?
Rust
Constants
Immutability
How to define test-only dependencies?
Rust
Rust Cargo
Understanding and relationship between Box, ref, & and *
Pointers
Rust
Need holistic explanation about Rust's cell and reference counted types
Rust
What does "dyn" mean in a type?
Syntax
Rust
How to get a reference to a concrete type from a trait object?
Rust
Traits
How to implement Iterator and IntoIterator for a simple struct?
Iterator
Rust
How to print structs and arrays?
Rust
How to uninstall Rust that was installed via rustup?
Rust
Rustup
References to traits in structs
Rust
Traits
How can I list files of a directory in Rust?
Rust
What does "cannot move out of index of" mean?
Rust
How to raise a number to a power?
Rust
Operators
Exponentiation
How to iterate a Vec<T> with the indexed position?
For Loop
Rust
Iterator
How to compose functions in Rust?
Functional Programming
Rust
Is there a good way to convert a Vec<T> to an array?
Rust
Is it possible for one struct to extend an existing struct, keeping all the fields?
Inheritance
Struct
Rust
Get the String length in characters in Rust
Rust
Cross-compile a Rust application from Linux to Windows
Linux
Windows
Rust
Cross Compiling
Why are recursive struct types illegal in Rust?
Rust
println! error: expected a literal / format argument must be a string literal
Rust
How does one round a floating point number to a specified number of digits?
Rust
How to convert the PathBuf to String
String
Rust
Directory
Path
How do I implement Copy and Clone for a type that contains a String (or any type that doesn't implement Copy)?
Rust
How do I implement the Add trait for a reference to a struct?
Reference
Rust
Traits
Lifetime
What makes something a "trait object"?
Rust
Traits
Trait Objects
Proper way to return a new string in Rust
Rust
What is this unwrap thing: sometimes it's unwrap sometimes it's unwrap_or
Rust
Vector of objects belonging to a trait
Polymorphism
Rust
How do I match enum values with an integer?
Rust
How do you access enum values in Rust?
Rust
Remove an element from a vector
Rust
How to check if a string contains a substring in Rust?
String
Rust
Return local String as a slice (&str)
Rust
Does println! borrow or own the variable?
Rust
Ownership
How do I convert a Vec<String> to Vec<&str>?
String
Vector
Rust
Type Conversion
How can I create enums with constant values in Rust?
Rust
How to link to other fns/structs/enums/traits in rustdoc?
Rust
Rustdoc
How do I convert between String, &str, Vec<u8> and &[u8]?
String
Rust
Type Conversion
How do I get an absolute value in Rust?
Rust
How do I store a closure in a struct in Rust?
Closures
Rust
How do I get an enum as a string?
Rust
How do I print output without a trailing newline in Rust?
Rust
Newline
Println
How to get a release build with debugging information when using cargo?
Rust
Rust Cargo
How to not do anything on the "rest case" when matching a string?
Rust
What are Some and None?
Rust
Optional
More concise HashMap initialization
Rust
Hashmap
How do I see the expanded macro code that's causing my compile error?
Debugging
Rust
Rust Macros
Rust Proc-Macros
Rust Decl-Macros
How can I create a function with a variable number of arguments?
Rust
Variadic Functions
What does the question mark mean in a type parameter bound?
Generics
Rust
Meaning of the ampersand '&' and star '*' symbols in Rust
Reference
Rust
Dereference
Ampersand
How does Rust implement reflection?
Reflection
Rust
Is there a way to simplify converting an Option into a Result without a macro?
Rust
Is it possible to make a recursive closure in Rust?
Recursion
Closures
Rust
Lifetimes in Rust
Rust
Lifetime
How do you use parent module imports in Rust?
Rust
Are semicolons optional in Rust?
Syntax
Rust
How do I parse a JSON File?
Json
Rust
How do you define custom `Error` types in Rust?
Error Handling
Rust
How do I convert a string into a vector of bytes in rust?
Type Conversion
Rust
How to compare enum without pattern matching
Enums
Pattern Matching
Rust
Why doesn't Rust support trait object upcasting?
Oop
Rust
Language Design
Liskov Substitution-Principle
How does Rust provide move semantics?
Rust
Move Semantics
What does the box keyword do?
Rust
How to get assembly output from building with Cargo?
Assembly
Rust
Rust Cargo
How do I check if a thing is in a vector
Rust
Does Rust have support for functions that return multiple values?
Rust
Repeat string with integer multiplication
Rust
How do I replace specific characters idiomatically in Rust?
Regex
Rust
How do I get an owned value out of a `Box`?
Rust
Unsafe
error[E0554]: #![feature] may not be used on the stable release channel Couldn't install racer using cargo
Rust
Rust Cargo
How do I write a multi-line string in Rust?
Rust
How to implement a custom 'fmt::Debug' trait?
Rust
How to specify const array in global scope in Rust?
Arrays
Static
Literals
Rust
What is the purpose of the unit type in Rust?
Rust
Unit Type
Why do try!() and ? not compile when used in a function that doesn't return Option or Result?
Rust
How can I create parameterized tests in Rust?
Unit Testing
Testing
Rust
How can I implement Rust's Copy trait?
Rust
Traits
Why can't the C compiler optimize changing the value of a const pointer assuming that two pointers to the same variable would be illegal/UB?
C
Rust
Undefined Behavior
Strict Aliasing
Why can't this higher kinded lifetime associated type trait bound be satisfied?
Rust
How can I specify binary-only dependencies?
Rust
Rust Cargo
The compiler suggests I add a 'static lifetime because the parameter type may not live long enough, but I don't think that's what I want
Rust
Lifetime
When or why should I use a Mutex over an RwLock?
Multithreading
Rust
Mutex
Readwritelock
Cannot borrow as mutable because it is also borrowed as immutable
Reference
Rust
What are the similarities and differences between C++'s concepts and Rust's traits?
C++
Rust
Traits
C++ Concepts
Changes using mutable reference of a field are not reflected after move of the original instance
Rust
Reference
Move
Why is it called "Rust"?
Naming
Rust
How do I borrow a reference to what is inside an Option<T>?
Rust
Is there a way to print enum values?
Enums
Rust
What is a clean way to convert a Result into an Option?
Rust
Optional
How do I sum a vector using fold?
Vector
Rust
Convert float to integer in Rust
Rust
Is it possible to use `impl Trait` as a function's return type in a trait definition?
Rust
Traits
Is it possible to conditionally enable an attribute like `derive`?
Rust
How do I create a Vec from a range and shuffle it?
Iterator
Immutability
Rust
Mutability
How can I download Rust API docs?
Rust
Compare enums only by variant, not value
Rust
What is the prelude?
Rust
Build HashSet from a vector in Rust
Vector
Rust
Hashset
Why is a borrowed range not an iterator, but the range is?
Rust
Reference
Iterator
Creating two dimensional arrays in Rust
Arrays
Vector
Multidimensional Array
Rust
Converting number primitives (i32, f64, etc) to byte representations
Types
Rust
How do I create a map from a list in a functional way?
Rust
How do I import from a sibling module?
Import
Rust
How to create an in-memory object that can be used as a Reader, Writer, or Seek in Rust?
Rust
In Memory
How to allow optional trailing commas in macros?
Macros
Rust
How is Rust compiled to machine code?
Rust
How do I "use" or import a local Rust file?
Import
Rust
How to launch a Rust application from Visual Studio Code?
Rust
Visual Studio-Code
Rust Cargo
Rls
How can I convert char to string?
Rust
Rust Obsolete
Lazy sequence generation in Rust
Rust
Lazy Sequences
A local function in Rust
Rust
How do I collect into an array?
Rust
What is the difference between passing a value to a function by reference and passing it by Box?
Rust
How do I implement a trait I don't own for a type I don't own?
Rust
Traits
Reversing a string in Rust
Rust
I implemented a trait for another trait but cannot call methods from both traits
Rust
Traits
How can I read a single line from stdin?
Rust
Unwrap inner type when enum variant is known
Enums
Rust
How can I read user input in Rust?
Input
Io
Rust
Does Rust support Ruby-like string interpolation?
Rust
String Interpolation
How do I do a basic import/include of a function from one module to another in Rust 2015?
Module
Rust
How to send output to stderr?
Rust
Stdio
How to switch between Rust toolchains?
Rust
Rustup
When is it useful to define multiple lifetimes in a struct?
Rust
Lifetime
Why is the `Sized` bound necessary in this trait?
Rust
Traits
How to generate statically linked executables?
Rust
Static Linking
How can I pass a reference to a stack variable to a thread?
Multithreading
Rust
Reference
Lifetime
How to set a Rust array length dynamically?
Arrays
Rust
What is the bitwise NOT operator in Rust?
Rust
Operators
What is typestate?
Rust
Language Design
Rust Obsolete
How to create a static array of strings?
Arrays
String
Static
Rust
Show u8 slice in hex representation
Hex
Rust
Slice
Why does printing a pointer print the same thing as printing the dereferenced pointer?
Pointers
Rust
Dereference
How to idiomatically copy a slice?
Rust
Slice
What does the ampersand (&) before `self` mean in Rust?
Variables
Syntax
Rust
How to suppress "function is never used" warning for a function used by tests?
Rust
How do I make an Rust item public within a crate, but private outside it?
Module
Rust
Public
Rust Crates
How to iterate through a Hashmap, print the key/value and remove the value in Rust?
Hashmap
Rust
Iteration
Mutability
How do I tell VS code what toolchain I want to use?
Rust
Visual Studio-Code
Why do I need to import a trait to use the methods it defines for a type?
Rust
How can I get cargo to recompile changed files automatically?
Rust
Rust Cargo
What's the idiomatic way to append a slice to a vector?
Vector
Rust
How to iterate over and filter an array?
Rust
How can I generate a random number within a range in Rust?
Random
Rust
Rust Obsolete
How do I exit a Rust program early from outside the main function?
System
Rust
Named breaks in for loops in Rust
For Loop
Break
Rust
Are nested structs supported in Rust?
Struct
Rust
How to clone a struct storing a boxed trait object?
Struct
Clone
Rust
Traits
Cloneable
How do I specify lifetime parameters in an associated type?
Rust
Lifetime
How to idiomatically convert between u32 and usize?
Types
Rust
Type Conversion
Is it considered a bad practice to implement Deref for newtypes?
Rust
Dereference
What are the performance impacts of 'functional' Rust?
Functional Programming
Rust
Imperative Programming