为什么编译器建议在模块中使用自己?

时间:2019-05-04 15:03:51

标签: rust

我有以下模块:

mod types {
    use std::str::FromStr;

    struct StringParseError;

    pub enum ProcStat {
        PSRunning,
    }

    impl FromStr for ProcStat {
        type Err = StringParseError;

        fn from_str(s: &str) -> Result<Self, Self::Err> {
            match s {
                "R" => Ok(PSRunning),
            }
        }
    }
}

在建造时,我得到了:

error[E0425]: cannot find value `PSRunning` in this scope
  --> src/lib.rs:15:27
   |
15 |                 "R" => Ok(PSRunning),
   |                           ^^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
   |
2  |     use crate::types::ProcStat::PSRunning;
   |

这里的正确用法是什么?我可能已经错过了文档中的这一部分。

0 个答案:

没有答案