Skip to content

Commit 456d208

Browse files
Merge pull request #69 from doitian/fix/rust-patterns-code-fence-formatting
fix(rust-patterns-book): correct markdown code fence formatting
2 parents 2d6e6b5 + 318327d commit 456d208

3 files changed

Lines changed: 6 additions & 27 deletions

File tree

‎rust-patterns-book/src/ch13-macros-code-that-writes-code.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ Derive macros live in a separate crate (`proc-macro = true`) and transform
271271
a token stream using `syn` (parse Rust) and `quote` (generate Rust):
272272

273273
```toml
274-
```
275-
276274
# my_derive/Cargo.toml
277275
[lib]
278276
proc-macro = true
@@ -281,6 +279,7 @@ proc-macro = true
281279
syn = { version = "2", features = ["full"] }
282280
quote = "1"
283281
proc-macro2 = "1"
282+
```
284283

285284
```rust
286285
// my_derive/src/lib.rs

‎rust-patterns-book/src/ch15-crate-architecture-and-api-design.md‎

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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]
567565
default = ["json"] # Enabled by default
@@ -573,6 +571,7 @@ full = ["json", "xml"] # Meta-feature: enables all
573571
serde = "1"
574572
serde_json = { version = "1", optional = true }
575573
quick-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");
601600
For large projects, use a Cargo workspace to share dependencies and build artifacts:
602601

603602
```toml
604-
```
605-
606603
# Root Cargo.toml
607604
[workspace]
608605
members = [
@@ -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/`)
639634
customizes 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

671663
Common 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
769757
cargo install cargo-deny
770758
cargo install cargo-audit
@@ -774,16 +762,11 @@ cargo audit
774762

775763
# Comprehensive checks: licenses, bans, advisories, sources
776764
cargo deny check
777-
778-
```rust
765+
```
779766

780767
Configure `cargo deny` with a `deny.toml` at the workspace root:
781768

782-
```
783-
784769
```toml
785-
```
786-
787770
# deny.toml
788771
[advisories]
789772
vulnerability = "deny" # Fail on known vulnerabilities
@@ -796,8 +779,6 @@ deny = ["GPL-3.0"] # Reject copyleft licenses
796779
[bans]
797780
multiple-versions = "warn" # Warn if multiple versions of same crate
798781
deny = [
799-
800-
```rust
801782
{ name = "openssl" }, # Force use of rustls instead
802783
]
803784

‎rust-patterns-book/src/ch16-asyncawait-essentials.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ async fn fetch_data(url: &str) -> Result<Vec<u8>, reqwest::Error> {
3737
### Tokio Quick Start
3838

3939
```toml
40-
```
41-
4240
# Cargo.toml
4341
[dependencies]
4442
tokio = { version = "1", features = ["full"] }
43+
```
4544

4645
```rust,ignore
4746
use tokio::time::{sleep, Duration};

0 commit comments

Comments
 (0)