| 1 | struct FooFoo { |
| 2 | pub mut: |
| 3 | conn Foo |
| 4 | } |
| 5 | |
| 6 | struct Foo { |
| 7 | host string = '127.0.0.1' |
| 8 | port u32 = 3306 |
| 9 | username string |
| 10 | password string |
| 11 | dbname string |
| 12 | } |
| 13 | |
| 14 | fn test_struct_init_and_assign() { |
| 15 | mut sql_ := FooFoo{} |
| 16 | sql_.conn = Foo{ |
| 17 | username: 'username' |
| 18 | password: 'abc' |
| 19 | dbname: 'test' |
| 20 | } |
| 21 | assert sql_.conn.host == '127.0.0.1' |
| 22 | assert sql_.conn.port == 3306 |
| 23 | assert sql_.conn.username == 'username' |
| 24 | assert sql_.conn.password == 'abc' |
| 25 | assert sql_.conn.dbname == 'test' |
| 26 | } |
| 27 | |