Docs: https://doc.rust-lang.org/std/iter/
#Rust30by30
Docs: https://doc.rust-lang.org/std/iter/
#Rust30by30
❌ DON'T:
- Be afraid to ask for help
- Hesitate to share your knowledge, no matter your skill level
Remember: Every contribution, big or small, helps the Rust ecosystem grow! 🦀
#Rust30by30
❌ DON'T:
- Be afraid to ask for help
- Hesitate to share your knowledge, no matter your skill level
Remember: Every contribution, big or small, helps the Rust ecosystem grow! 🦀
#Rust30by30
You even get the file and line number, for free!
#Rustlang #Debugging #Rust30by30 #Day2
You even get the file and line number, for free!
#Rustlang #Debugging #Rust30by30 #Day2
❌ DON'T: Reinvent the wheel with custom data structures.
Sidenote: A HashSet is implemented as a HashMap where the value is the empty tuple (). So HashSet
#Rustlang #Rust30by30
❌ DON'T: Reinvent the wheel with custom data structures.
Sidenote: A HashSet is implemented as a HashMap where the value is the empty tuple (). So HashSet
#Rustlang #Rust30by30
This allows you to add new variants later without breaking existing code.
This attribute forces people to have a _ pattern in their matches that will match any items you add later.
#Rust30by30
This allows you to add new variants later without breaking existing code.
This attribute forces people to have a _ pattern in their matches that will match any items you add later.
#Rust30by30
Run all tests: cargo test
Run ignored tests: cargo test -- --ignored
This helps keep your test suite fast while still allowing those long running tests when needed!
#RustTesting #Rust30by30 #Day15
Run all tests: cargo test
Run ignored tests: cargo test -- --ignored
This helps keep your test suite fast while still allowing those long running tests when needed!
#RustTesting #Rust30by30 #Day15
It skips building everything but still checks your code for any compilation errors!
You can also use cargo watch to automatically run cargo check!
#RustTricks #Rust30by30 #Day8
It skips building everything but still checks your code for any compilation errors!
You can also use cargo watch to automatically run cargo check!
#RustTricks #Rust30by30 #Day8
It's also a great learning tool! It will show you best practices to follow, and by reading and understanding the suggestions you can improve your skills as a Rust developer!
#Rust30by30 #Day14
It's also a great learning tool! It will show you best practices to follow, and by reading and understanding the suggestions you can improve your skills as a Rust developer!
#Rust30by30 #Day14
Doc comments use three slashes /// and support Markdown
They appear in the generated documentation
Regular won't be included in the documentation.
example:
Run `cargo doc --open` to generate and view your documentation!
#Rust30by30
Doc comments use three slashes /// and support Markdown
They appear in the generated documentation
Regular won't be included in the documentation.
example:
Run `cargo doc --open` to generate and view your documentation!
#Rust30by30
This is also not limited to Default::default() it will work with any instance of your struct!
#Rust30by30 #Day11
This is also not limited to Default::default() it will work with any instance of your struct!
#Rust30by30 #Day11
📝 You can even setup your editor to Auto-Format on save!
VS Code Instructions:
- Install the Rust Analyzer extension
- Open settings
- Search for "Format on Save" and enable it
#RustTips #Rust30by30 #Day12
📝 You can even setup your editor to Auto-Format on save!
VS Code Instructions:
- Install the Rust Analyzer extension
- Open settings
- Search for "Format on Save" and enable it
#RustTips #Rust30by30 #Day12
Rust doesn't have null values, but it does have Option
This lets the compiler help check for those pesky "null" cases for you, and make sure you handle the Option::None case!
#RustTricks #Rust30by30 #Day9
Rust doesn't have null values, but it does have Option
This lets the compiler help check for those pesky "null" cases for you, and make sure you handle the Option::None case!
#RustTricks #Rust30by30 #Day9
Use the #[derive(Debug, Clone)] attribute to automatically generate implementations for the Debug and Clone traits.
💡 Clone is useful when you need a copy of the struct
💡 Debug is useful for printing the struct for debugging, try with dbg!
#Rust30by30 #Day6
Use the #[derive(Debug, Clone)] attribute to automatically generate implementations for the Debug and Clone traits.
💡 Clone is useful when you need a copy of the struct
💡 Debug is useful for printing the struct for debugging, try with dbg!
#Rust30by30 #Day6
They are a way to define methods that multiple types can implement, enabling polymorphism!
With traits you can write functions that accept different types, that all have a common behavior.
All while maintaining type safety!
#Rust30by30 #Rustlang #Day4
They are a way to define methods that multiple types can implement, enabling polymorphism!
With traits you can write functions that accept different types, that all have a common behavior.
All while maintaining type safety!
#Rust30by30 #Rustlang #Day4
#RustFormatting #Rust30by30 #Day18
#RustFormatting #Rust30by30 #Day18
#RustPerformance #Rust30by30 #Day17
#RustPerformance #Rust30by30 #Day17
Be careful though, if you overestimate the size of the vector you will waste memory!
#RustCollections #Rust30by30 #Day16
Be careful though, if you overestimate the size of the vector you will waste memory!
#RustCollections #Rust30by30 #Day16
cargo expand allows you to see the expanded code generated by macros, providing more insight into what's happening under the hood
Learn more here: https://docs.rs/crate/cargo-expand/0.1.3/source/README.md
#RustMacros #Rust30by30 #Day13
cargo expand allows you to see the expanded code generated by macros, providing more insight into what's happening under the hood
Learn more here: https://docs.rs/crate/cargo-expand/0.1.3/source/README.md
#RustMacros #Rust30by30 #Day13
Be careful though, for Strings field, the default implementation will create an empty string!
#RustTricks #Rust30by30 #Day10
Be careful though, for Strings field, the default implementation will create an empty string!
#RustTricks #Rust30by30 #Day10
• ❓ ? operator, to forward the error up the call stack
• 🧩 match
📚 Read more: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html
#ErrorHandling #Rust30by30 #Day5
2/2
• ❓ ? operator, to forward the error up the call stack
• 🧩 match
📚 Read more: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html
#ErrorHandling #Rust30by30 #Day5
2/2
✅ DO: Use Rust's built-in testing framework to write unit tests and integration tests.
❌ DON'T: Skip testing, it's crucial for maintainable code! #RustTesting #TDD
Run `cargo test` to see the output!
Learn more: https://buff.ly/3XZHtbu
#Rust30by30 #Day3
✅ DO: Use Rust's built-in testing framework to write unit tests and integration tests.
❌ DON'T: Skip testing, it's crucial for maintainable code! #RustTesting #TDD
Run `cargo test` to see the output!
Learn more: https://buff.ly/3XZHtbu
#Rust30by30 #Day3
```rust
let a = 1;
let b = 2;
let (a, b) = (b, a);
println!("{}, {}",a,b);
//output: 2, 1
```
#Rust30by30 #Rustc #Rustlang #Day1
```rust
let a = 1;
let b = 2;
let (a, b) = (b, a);
println!("{}, {}",a,b);
//output: 2, 1
```
#Rust30by30 #Rustc #Rustlang #Day1