[][src]Function tao_of_rust::ch02::primitives::str_type

pub fn str_type()

基本数据类型:str字符串类型

Basic usage:

fn str_type(){
    let truth = "Rust是一门优雅的语言";
    let ptr = truth.as_ptr();
    let len = truth.len();
    assert_eq!(28, len);
    let s = unsafe {
        let slice = std::slice::from_raw_parts(ptr, len);
        std::str::from_utf8(slice)
    };
    assert_eq!(s, Ok(truth));
}
str_type();Run