File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,26 @@ Where `main.rs` contains:
3030
3131``` rust ignore
3232#![debugger_visualizer(natvis_file = " ../Rectangle.natvis" )]
33- struct FancyRect {
33+ mod fancy_rect {
34+ pub struct FancyRect {
3435 pub x : f32 ,
3536 pub y : f32 ,
3637 pub dx : f32 ,
3738 pub dy : f32 ,
39+ }
40+
41+ impl FancyRect {
42+ pub fn new (x : f32 , y : f32 , dx : f32 , dy : f32 ) -> Self {
43+ FancyRect { x , y , dx , dy }
44+ }
45+ }
3846}
3947
48+ use fancy_rect :: FancyRect ;
49+
4050fn main () {
4151 let fancy_rect = FancyRect :: new (10.0 , 10.0 , 5.0 , 5.0 );
42- Ok (());
52+ ()
4353}
4454```
4555
@@ -108,13 +118,19 @@ mod person {
108118 pub name : String ,
109119 pub age : i32 ,
110120 }
121+
122+ impl Person {
123+ pub fn new (name : String , age : i32 ) -> Self {
124+ Person { name , age }
125+ }
126+ }
111127}
112128
113129use person :: Person ;
114130
115131fn main () {
116132 let bob = Person :: new (String :: from (" Bob" ), 10 );
117- Ok (());
133+ ()
118134}
119135```
120136
You can’t perform that action at this time.
0 commit comments