- Capture groups:
use regex::Regex; let re = Regex::new(r"(\w+)").unwrap(); let text = "Hello world"; for cap in re.captures_iter(text) { println!("Match: {}", &cap[1]); } - Named capture groups:
use regex::Regex; let re = Regex::new(r"(?<word>\w+)").unwrap(); let text = "Hello world"; for cap in re.captures_iter(text) { println!("Match: {}", &cap["word"]); }
Search This Blog
Showing posts with label rust. Show all posts
Showing posts with label rust. Show all posts
Regular Expression Capture Groups
Setup Neovim for Rust Development
- Install Neovim
- Install AstroNvim
- After installed AstroNvim, you can customise it
- Install rust LSP
In Neovim, execute command::LspInstall rust
- Install rust language parser (tree-sitter)
In Neovim, execute command::TSInstall rust
- Install lua language parser (tree-sitter)
In Neovim, execute command::TSInstall lua
This is useful for editting the Neovim config (lua) files (*.lua)
See also
Change Rust install location
By default, Rust will be installed to home directory:
~/.cargo and ~/.rustup. To change the location,
- Set CARGO_HOME and RUSTUP_HOME environment variable before installation
- Install Rust using rust-init
- Update PATH environment variable to install
$CARGO_HOME/bin
see also
Install Rust on Windows 10 with msys2
- Install MSYS2
- Update MSYS2 packages by executing
pacman -Sy pacman -Syu
in MSYS2 Terminal - Install git and mingw-w64-x86_64-toolchain in MSYS2 terminal:
pacman -S git pacman -S mingw-w64-x86_64-toolchain
- Install mingw-w64-x86_64-rust in MSYS2 terminal:
pacman -S mingw-w64-x86_64-rust
Now the rust compiler is installed. You can stop here if you do not need rustup to manage the Rust compiler environment. - To use rustup, clone the git repository:
git clone https://github.com/rust-lang/rustup.git
- Compile and run rustup:
cd rustup cargo run --release
Rustup will detects the previous install rust compiler and asks to uninstall it before you can continue. You need to open a new MSYS2 terminal and runpacman -R mingw-w64-x86_64-rust
and then go back to the rustup installation terminal, choose yes to continue the installation.
On the next question choose: Custom installation and chose as host triple: x86_64-pc-windows-gnu - After rustup installation, the cargo command will be install to $HOME/.cargo/bin. You will need to install it in your PATH environment variable.
Install Rust on Windows 10
- Download and install Microsoft C++ Build Tools
- while installing, check Desktop development with C++ under Workloads tab.
- Download rust-init.exe from https://www.rust-lang.org/tools/install, and execute it to install.
see also
- https://www.rust-lang.org/tools/install
- rustup does not recognize Visual C++ Build Tools
Subscribe to:
Posts (Atom)