📜  rust struct - Rust 代码示例

📅  最后修改于: 2022-03-11 14:49:25.109000             🧑  作者: Mango

代码示例1
struct Data {
    randomInfo: String
}

let mut Data {
    randomInfo: "This is a structure"
}

/* 
 The mut keyword defines whether or not you can mutate (change)
 the variable (in this case a structure), so if you don't want tp be able to 
 change the data then don't use the mut keyword. Like so:
*/

let Data {
    randomInfo: "This is a structure"
}