原书出处
Rust编程之道
08 字符串与集合类型 8.1 字符串
ring类型实现了From trait。
代码第6行,通过String::with_capacity方法来创建空字符串,但是与String::new方法不同的是,with_capacity方法接收一个usize类型的参数,用于指定创建字符串预先要在堆上分配的容量空间。
此例中指定的参数是20,则会在堆中分配至
原书定位详情
来源:a19c7933-4eda-4176-aebd-30fe7e1ad292
正文位置:extracted/Rust编程之道/_epub-src/text/part0014_split_001.html
EPUB SHA-256:585074c6844ba06a529a7623f659130564e9907ec38a9d661f661974f9787ac8