fix compile errors in code snippets

This commit is contained in:
Gibby Free 2023-03-06 16:35:32 -08:00 committed by Eric Huss
parent 1c56d59ddd
commit 4dee364a2c
1 changed files with 19 additions and 3 deletions

View File

@ -30,16 +30,26 @@ Where `main.rs` contains:
```rust ignore
#![debugger_visualizer(natvis_file = "../Rectangle.natvis")]
struct FancyRect {
mod fancy_rect {
pub struct FancyRect {
pub x: f32,
pub y: f32,
pub dx: f32,
pub dy: f32,
}
impl FancyRect {
pub fn new(x: f32, y: f32, dx: f32, dy: f32) -> Self {
FancyRect { x, y, dx, dy }
}
}
}
use fancy_rect::FancyRect;
fn main() {
let fancy_rect = FancyRect::new(10.0, 10.0, 5.0, 5.0);
Ok(());
()
}
```
@ -108,13 +118,19 @@ mod person {
pub name: String,
pub age: i32,
}
impl Person {
pub fn new(name: String, age: i32) -> Self {
Person { name, age }
}
}
}
use person::Person;
fn main() {
let bob = Person::new(String::from("Bob"), 10);
Ok(());
()
}
```