问题描述
从 here 我了解到 components
方法在 Components
的 std::path::Path
上生成迭代器。特别地,Components
类型定义为:
pub struct Components<'a> {
// The path left to parse components from
path: &'a [u8],// The prefix as it was originally parsed,if any
prefix: Option<Prefix<'a>>,// true if path *physically* has a root separator; for most Windows
// prefixes,it may have a "logical" rootseparator for the purposes of
// normalization,e.g.,\\server\share == \\server\share\.
has_physical_root: bool,// The iterator is double-ended,and these two states keep track of what has
// been produced from either end
front: State,back: State,}
因此,
pub fn components(&self) -> Components<'_> {
let prefix = parse_prefix(self.as_os_str());
Components {
path: self.as_u8_slice(),prefix,has_physical_root: has_physical_root(self.as_u8_slice(),prefix)
|| has_redox_scheme(self.as_u8_slice()),front: State::Prefix,back: State::Body,}
}
然而,我仍然难以理解正在运行的迭代器。如果有人能解释(最好用一个例子)Components
成员在每次调用绝对和/或相对路径的 next
方法后持有什么,我将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)