Rust Note - 01
记录一些离散的知识点/感悟
String 和 &str String -> &str : .as_str() &str -> String : .to_string() 其次是编写函数的参数类型选择上,基本原则是:&str只是副本,函数是只需要获得其值,还是真的需要获得“本尊”?
enum to String 在python中,转换成str类需要实现
_str_方法
在rust中,则需要实现Display这个trait,然后用 to_string()方法
- array to vec
1
cast_slice(bitmap_data_u8).to_vec();
This post is licensed under CC BY 4.0 by the author.