compound-types/struct #169
Replies: 41 comments 7 replies
-
struct Color(i32, i32, i32); fn check_color(p: Point) { check_color()中,let Point(x, _, _) = p; 这一句发生了所有权转移吗? |
Beta Was this translation helpful? Give feedback.
-
Done,对于结构体的所有权设计我并不是很能理解结构体的所有权和他的属性的所有权是分开的。这样做的优点是什么? |
Beta Was this translation helpful? Give feedback.
-
变量绑定时所有权是否移动,可不可以理解为,只要类型实现了Copy trait,就自动拷贝,所有权不移动,原变量可以继续使用,如果没有实现则发生所有权移动,原变量不可以使用? |
Beta Was this translation helpful? Give feedback.
-
Done. |
Beta Was this translation helpful? Give feedback.
-
Done. 第8道有点想不到既然是这样就可以了 |
Beta Was this translation helpful? Give feedback.
-
Done. |
Beta Was this translation helpful? Give feedback.
-
2022.11.14 Done |
Beta Was this translation helpful? Give feedback.
-
结构体还有一个存在,struct FakeUnit {} |
Beta Was this translation helpful? Give feedback.
-
done |
Beta Was this translation helpful? Give feedback.
-
Done.第三题卡了一下,没想到如何解构出Color内的字段值,看了几次https://course.rs/basic/compound-type/struct.html#%E5%85%83%E7%BB%84%E7%BB%93%E6%9E%84%E4%BD%93tuple-struct 也没理解,在后面看到了 let Peron {name,age} 这个声明,想到应该也是一样的吧。概念是真的多=_= |
Beta Was this translation helpful? Give feedback.
-
mark |
Beta Was this translation helpful? Give feedback.
-
这写起来确实限制很多,从java看过来... |
Beta Was this translation helpful? Give feedback.
-
done |
Beta Was this translation helpful? Give feedback.
-
mark |
Beta Was this translation helpful? Give feedback.
-
个人建议3题是不是将要求改为 :修复错误并填空 好些,原有的填空并修复错误。 容易理解为 仅用填空的方式就能修复错误。 |
Beta Was this translation helpful? Give feedback.
-
Done. 被第三题卡了,没看仔细,将_看成__了,在疑惑(x, _, _)两个_填什么0.o,哈哈🤣 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Done |
Beta Was this translation helpful? Give feedback.
-
done. |
Beta Was this translation helpful? Give feedback.
-
done~~~ |
Beta Was this translation helpful? Give feedback.
-
mark finished |
Beta Was this translation helpful? Give feedback.
-
// Fix the error and fill the blanks
} fn check_color(p: Color) { Answer` // Fix the error and fill the blanks
} fn check_color(p: Color) { |
Beta Was this translation helpful? Give feedback.
-
done |
Beta Was this translation helpful? Give feedback.
-
Done |
Beta Was this translation helpful? Give feedback.
-
done |
Beta Was this translation helpful? Give feedback.
-
done |
Beta Was this translation helpful? Give feedback.
-
打卡 |
Beta Was this translation helpful? Give feedback.
-
Done |
Beta Was this translation helpful? Give feedback.
-
success(8/8) |
Beta Was this translation helpful? Give feedback.
-
done |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
compound-types/struct
Learning Rust By Practice, narrowing the gap between beginner and skilled-dev with challenging examples, exercises and projects.
https://zh.practice.rs/compound-types/struct.html
Beta Was this translation helpful? Give feedback.
All reactions