[英]What is the best way of handling error in rust? (CLI with clap)
[英]what is the correct way to get ownership of an argument with clap?
我想通过一个拥有其值所有权的Config
-struct 传递我的 CLI 程序的选项,即String
的路径。 现在已弃用的ArgMatches::values_of_lossy()
返回一个拥有的String
,但是, ArgMatches::get_many()
只返回一个ValuesRef<>
。 获得论点本身所有权的最佳方法是什么,最好不要克隆?
ArgMatches::remove_many
将通过将这些值移出ArgMatches
结构来赋予您所有权。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.