I'm currently studying rust-lang following the direction of:
- O'Reilly Programming Rust - Jim Blandy, Jason Orendorff & Leonara F. S. Tindall
- Zero to Production in Rust - Luca Palmieri
-
Rust toolchain via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Verify:
rustc --version cargo --version
-
rust-analyzer (the Rust LSP server):
rustup component add rust-analyzer
Verify:
rust-analyzer --version
-
clippy and rustfmt:
rustup component add clippy rustfmt
-
Vim 9.0+ with
+channeland+jobsupport (check withvim --version).
We use yegappan/lsp, a Vim9-native LSP client. Install it with Vim's built-in package manager — no external plugin manager needed:
mkdir -p ~/.vim/pack/plugins/start
git clone https://github.com/yegappan/lsp.git ~/.vim/pack/plugins/start/lspAdd the following to ~/.vimrc:
" General settings
set nocompatible
syntax on
filetype plugin indent on
set number
set relativenumber
set signcolumn=yes
set updatetime=300
set completeopt=menuone,popup,noinsert,noselect
" Rust file settings
autocmd FileType rust setlocal tabstop=4 shiftwidth=4 expandtab
" LSP configuration (yegappan/lsp with rust-analyzer)
let lspServers = [
\ #{
\ name: 'rust-analyzer',
\ filetype: ['rust'],
\ path: expand('~/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer'),
\ args: [],
\ syncInit: v:true,
\ }
\ ]
autocmd VimEnter * call LspAddServer(lspServers)
" LSP keybindings
autocmd FileType rust nnoremap gd :LspGotoDefinition<CR>
autocmd FileType rust nnoremap gr :LspShowReferences<CR>
autocmd FileType rust nnoremap gi :LspGotoImpl<CR>
autocmd FileType rust nnoremap K :LspHover<CR>
autocmd FileType rust nnoremap <leader>rn :LspRename<CR>
autocmd FileType rust nnoremap <leader>ca :LspCodeAction<CR>
autocmd FileType rust nnoremap [d :LspDiagPrev<CR>
autocmd FileType rust nnoremap ]d :LspDiagNext<CR>
autocmd FileType rust nnoremap <leader>d :LspDiagCurrent<CR>From the command line:
# Project compiles
cargo check
# Clippy passes
cargo clippy
# Formatting is correct
cargo fmt --check
# rust-analyzer can analyze the project
rust-analyzer analysis-stats .From inside Vim:
- Open a Rust file:
vim src/main.rs - Verify LSP is running:
:LspServerStatus— should show rust-analyzer as running. - Test go-to-definition: place cursor on
println!and pressgd. - Test hover: press
Kon any symbol to see type info. - Test diagnostics: introduce a type error and check that
[d/]dnavigate between errors.
| Key | Action |
|---|---|
gd |
Go to definition |
gr |
Show references |
gi |
Go to implementation |
K |
Hover documentation |
<leader>rn |
Rename symbol |
<leader>ca |
Code action |
[d / ]d |
Previous / next diagnostic |
<leader>d |
Show current diagnostic |
:LspDiagShow |
Open quickfix list with all diagnostics |
:LspDiagCurrent |
Get info on the highlighted error |
| Language | Executable Size (M1) | What is actually inside the file? | The "Why Rust?" Perspective |
|---|---|---|---|
| Assembly (ARM64) | 16 K | Raw CPU instructions wrapped in an empty 16KB Mach-O envelope. | Ultimate Control: Absolute bare metal. Zero abstractions, zero safety nets. You are manually pushing bits. |
| C | 33 K | CPU instructions + a tiny dynamic link to the OS's libc. |
Fast but Unsafe: Tiny and lightning-fast, but relies on the OS. You are entirely responsible for manual memory management (which often leads to security vulnerabilities and crashes). |
| Rust | 435 K | CPU instructions + Rust's statically linked standard library. | The Sweet Spot: It statically links its own standard lib (hence 435K instead of 33K) so it can run independently anywhere. It gives you the memory safety of Python/Go, but with zero garbage collector and zero heavy runtime. |
| Go | 1.9 M | CPU instructions + standard lib + the Go Runtime (Garbage Collector). | Safe but Heavy: Great developer experience and built-in concurrency, but you pay a mandatory ~1.5MB "tax" for the garbage collector and runtime scheduler. |
| Python (PyInstaller) | 6.5 M | The Python C-interpreter + standard lib + your script. | Ultimate Convenience: Extremely easy to write, but massive overhead. You are shipping an entire software engine just to execute a text file. |