revive_llvm_builder/
build_type.rs

1//! The revive LLVM build type.
2
3/// The revive LLVM build type.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum BuildType {
6    /// The debug build.
7    Debug,
8    /// The release build.
9    Release,
10    /// The release with debug info build.
11    RelWithDebInfo,
12    /// The minimal size release build.
13    MinSizeRel,
14}
15
16impl std::str::FromStr for BuildType {
17    type Err = String;
18
19    fn from_str(value: &str) -> Result<Self, Self::Err> {
20        match value {
21            "Debug" => Ok(Self::Debug),
22            "Release" => Ok(Self::Release),
23            "RelWithDebInfo" => Ok(Self::RelWithDebInfo),
24            "MinSizeRel" => Ok(Self::MinSizeRel),
25            value => Err(format!("Unsupported build type: `{value}`")),
26        }
27    }
28}
29
30impl std::fmt::Display for BuildType {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        match self {
33            Self::Debug => write!(f, "Debug"),
34            Self::Release => write!(f, "Release"),
35            Self::RelWithDebInfo => write!(f, "RelWithDebInfo"),
36            Self::MinSizeRel => write!(f, "MinSizeRel"),
37        }
38    }
39}