如何输出结构体

提问

如何输出结构体

回答

  1. 给结构体增加特性

[derive(Debug)]

  1. 使用{:?}打印 不换行
  2. 使用{#:?} 打印 换行
  3. 使用dbg!(&rect1);

参考

https://course.rs/basic/compound-type/struct.html

posted @ 2024-07-15 11:31  喜爱糖葫芦  阅读(1)  评论(0编辑  收藏  举报