摘要: Example 1: trait AppendBar { fn append_bar(self) -> Self; } impl AppendBar for String { fn append_bar(mut self) -> Self { self.push_str("Bar"); return 阅读全文
posted @ 2024-03-23 17:47 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要: Example 1: fn main() { let mut shopping_list: Vec<&str> = Vec::new(); shopping_list.push("milk"); } Example 2: struct Wrapper<T> { value: T, } impl<T> 阅读全文
posted @ 2024-03-23 17:18 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑