摘要: 提问 如何输出结构体 回答 给结构体增加特性 [derive(Debug)] 使用{:?}打印 不换行 使用{#:?} 打印 换行 使用dbg!(&rect1); 参考 https://course.rs/basic/compound-type/struct.html 阅读全文
posted @ 2024-07-15 11:31 喜爱糖葫芦 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 提问 如何快速复制一个结构体 回答 结构体更新语法 let user2 = User { email: String::from("another@example.com"), ..user1 }; 因为 user2 仅仅在 email 上与 user1 不同,因此我们只需要对 email 进行赋值 阅读全文
posted @ 2024-07-15 11:20 喜爱糖葫芦 阅读(1) 评论(0) 推荐(0) 编辑