1 rust rules available
One Copilot rule matches rust: a Rust guidelines rule for systems code. Copilot completions are generated line by line, so the file focuses on patterns that keep suggestions idiomatic: Result propagation, borrowing and avoiding panics.
GitHub Copilot reads repository-wide custom instructions from .github/copilot-instructions.md and path-specific instructions from .github/instructions/*.instructions.md files with an applyTo glob. Copilot can also use AGENTS.md files, where the nearest file in the directory tree takes precedence. Which file types are honored depends on the surface: VS Code, Visual Studio, JetBrains, Xcode, Eclipse and GitHub.com differ.
.github/instructions/rust.instructions.mdStarting point, not a tested configuration for your repository. Used for files matching applyTo on surfaces that support path-specific instructions. Review the instructions, adapt the file paths and run your project's existing checks.
--- applyTo: "**/*.rs,**/Cargo.toml" --- # Rust instructions for GitHub Copilot ## Focus for this project - Complete fallible calls with ? inside functions that return Result, not unwrap(). - Take &[T] or &str parameters unless the function stores the value. - Generate #[cfg(test)] mod tests blocks with focused unit tests. ## Rust conventions - Read the edition and rust-version fields in Cargo.toml and stay within them; do not raise either without being asked. - Return Result from fallible functions and propagate with ?. No unwrap() or expect() outside tests, examples and documented invariants. - Borrow (&str, &[T]) in parameters where ownership is not needed, and avoid clone() added only to satisfy the borrow checker; explain any clone that remains. - Every unsafe block needs a // SAFETY: comment stating the invariant it relies on. ## Before you finish - Run cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - When reviewing a pull request, comment only where a change breaks one of these instructions and quote the instruction.
Create your own GitHub Copilot rules for Rust and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Instruction support differs by surface: VS Code supports repository-wide, path-specific and AGENTS.md instructions; Visual Studio supports repository-wide and path-specific; JetBrains and Xcode use .github/copilot-instructions.md. GitHub's documentation describes AGENTS.md files stored anywhere in the repository, with the nearest file in the directory tree taking precedence, or alternatively a single CLAUDE.md or GEMINI.md in the root. Support differs by surface; GitHub's IDE page lists AGENTS.md among the instruction types for VS Code.
Documentation checked 2026-11-05: GitHub Docs: Adding repository custom instructionsGitHub Docs: Repository instructions in your IDE
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You want Copilot completions in a Rust crate to propagate errors with ? and borrow slices instead of taking owned Vecs.
Type the signature: pub fn average(values:
A completion taking &[f64] and returning Option<f64> (None for an empty slice) rather than panicking, with a unit test.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.