31 lines
965 B
Markdown
31 lines
965 B
Markdown
DeaDvey's domain
|
|
|
|
[Home page](/index.md) [Blogs](/blog/index.md) [Resources](/resources/index.md)
|
|
---
|
|
***Rust:***
|
|
|
|
***Useful resources:***
|
|
- [Crates docs](https://docs.rs/)
|
|
|
|
**How to do some random things:**
|
|
- Colors and effects in the terminal with [Colored](https://docs.rs/colored/latest/colored/index.html):
|
|
%%%
|
|
// Cargo.toml
|
|
colored = "2.2.0"
|
|
|
|
// program.rs
|
|
use colored::Colorize;
|
|
|
|
println!("{}", "red text".red());
|
|
println!("{}", "green background".on_green());
|
|
println!("{}", "bold text".bold());
|
|
%%%
|
|
- Search and replace (example):
|
|
%%%
|
|
let strikethrough_regex = Regex::new(r"~~(.*?)~~").unwrap(); // Define the search pattern
|
|
|
|
let parsed_line: String = strikethrough_regex.replace_all(&parsed_line, |caps: ®ex::Captures| { // Assign a variable to the changed value, if there's a match
|
|
caps[1].strikethrough().to_string() // This is the replaced value, that is returned from this function
|
|
}).to_string();
|
|
%%%
|