@@ -560,8 +560,6 @@ system guarantees they're valid.
560560### Feature Flags and Conditional Compilation
561561
562562``` toml
563- ```
564-
565563# Cargo.toml
566564[features ]
567565default = [" json" ] # Enabled by default
@@ -573,6 +571,7 @@ full = ["json", "xml"] # Meta-feature: enables all
573571serde = " 1"
574572serde_json = { version = " 1" , optional = true }
575573quick-xml = { version = " 0.31" , optional = true }
574+ ```
576575
577576``` rust
578577// Conditional compilation based on features:
@@ -601,8 +600,6 @@ compile_error!("At least one format feature (json, xml) must be enabled");
601600For large projects, use a Cargo workspace to share dependencies and build artifacts:
602601
603602``` toml
604- ```
605-
606603# Root Cargo.toml
607604[workspace ]
608605members = [
@@ -622,11 +619,9 @@ tracing = "0.1"
622619# In each member's Cargo.toml:
623620# [dependencies]
624621# serde = { workspace = true }
625-
626- ``` rust
622+ ```
627623
628624** Benefits** :
629- ```
630625
631626- Single ` Cargo.lock ` — all crates use the same dependency versions
632627- ` cargo test --workspace ` runs all tests
@@ -639,8 +634,6 @@ The `.cargo/config.toml` file (at the workspace root or in `$HOME/.cargo/`)
639634customizes Cargo behavior without modifying ` Cargo.toml ` :
640635
641636``` toml
642- ```
643-
644637# .cargo/config.toml
645638
646639# Default target for this workspace
@@ -665,13 +658,10 @@ IPMI_LIB_PATH = "/usr/lib/bmc"
665658# Use a custom registry (for internal packages)
666659# [registries.internal]
667660# index = "https://gitlab.internal/crates/index"
668-
669- ``` rust
661+ ```
670662
671663Common configuration patterns:
672664
673- ```
674-
675665| Setting | Purpose | Example |
676666| ---------| ---------| ---------|
677667| ` [build] target ` | Default compilation target | ` x86_64-unknown-linux-musl ` for static builds |
@@ -763,8 +753,6 @@ extern "C" fn platform_ioctl(fd: i32, request: u64) -> i32;
763753### ` cargo deny ` and ` cargo audit ` : Supply-Chain Security
764754
765755``` bash
766- ```
767-
768756# Install security audit tools
769757cargo install cargo-deny
770758cargo install cargo-audit
@@ -774,16 +762,11 @@ cargo audit
774762
775763# Comprehensive checks: licenses, bans, advisories, sources
776764cargo deny check
777-
778- ``` rust
765+ ```
779766
780767Configure ` cargo deny ` with a ` deny.toml ` at the workspace root:
781768
782- ```
783-
784769``` toml
785- ```
786-
787770# deny.toml
788771[advisories ]
789772vulnerability = " deny" # Fail on known vulnerabilities
@@ -796,8 +779,6 @@ deny = ["GPL-3.0"] # Reject copyleft licenses
796779[bans ]
797780multiple-versions = " warn" # Warn if multiple versions of same crate
798781deny = [
799-
800- ``` rust
801782 { name = " openssl" }, # Force use of rustls instead
802783]
803784
0 commit comments