Sha256: 04b41bb9efa473a661785003c3ffcc250284fe25e6113a4c2582f5d74f39d046

Contents?: true

Size: 1.4 KB

Versions: 38

Compression:

Stored size: 1.4 KB

Contents

/// Represents the kind of search path.
#[derive(Debug, PartialEq, Eq)]
pub enum SearchPathKind {
    Native,
    Framework,
}

/// Represents a library taht can be linked with Cargo.
#[derive(Debug, PartialEq, Eq)]
pub struct SearchPath {
    pub kind: SearchPathKind,
    pub name: String,
}

impl From<&str> for SearchPathKind {
    fn from(s: &str) -> Self {
        match s {
            "framework" => SearchPathKind::Framework,
            "native" => SearchPathKind::Native,
            _ => panic!("Unknown lib kind: {}", s),
        }
    }
}

impl From<&str> for SearchPath {
    fn from(s: &str) -> Self {
        let parts: Vec<_> = s.split('=').collect();

        match parts.len() {
            1 => (SearchPathKind::Native, parts[0]).into(),
            2 => (parts[0], parts[1]).into(),
            _ => panic!("Invalid library specification: {}", s),
        }
    }
}

impl<K, T> From<(K, T)> for SearchPath
where
    K: Into<SearchPathKind>,
    T: Into<String>,
{
    fn from((kind, name): (K, T)) -> Self {
        Self {
            kind: kind.into(),
            name: name.into(),
        }
    }
}

impl std::fmt::Display for SearchPath {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self.kind {
            SearchPathKind::Framework => write!(f, "framework={}", self.name),
            SearchPathKind::Native => write!(f, "native={}", self.name),
        }
    }
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.108/src/rb_config/search_path.rs
wasmtime-28.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.108/src/rb_config/search_path.rs
wasmtime-27.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.103/src/rb_config/search_path.rs
wasmtime-26.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.102/src/rb_config/search_path.rs
wasmtime-25.0.2 ./ext/cargo-vendor/rb-sys-build-0.9.102/src/rb_config/search_path.rs
wasmtime-25.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.102/src/rb_config/search_path.rs
wasmtime-25.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.102/src/rb_config/search_path.rs
wasmtime-24.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.102/src/rb_config/search_path.rs
wasmtime-23.0.2 ./ext/cargo-vendor/rb-sys-build-0.9.100/src/rb_config/search_path.rs
wasmtime-22.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.100/src/rb_config/search_path.rs
wasmtime-21.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.100/src/rb_config/search_path.rs
wasmtime-20.0.2 ./ext/cargo-vendor/rb-sys-build-0.9.97/src/rb_config/search_path.rs
wasmtime-20.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.97/src/rb_config/search_path.rs
wasmtime-18.0.3 ./ext/cargo-vendor/rb-sys-build-0.9.89/src/rb_config/search_path.rs
wasmtime-17.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.86/src/rb_config/search_path.rs
wasmtime-17.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.86/src/rb_config/search_path.rs
wasmtime-16.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.86/src/rb_config/search_path.rs
wasmtime-15.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.86/src/rb_config/search_path.rs
wasmtime-15.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.86/src/rb_config/search_path.rs
wasmtime-14.0.4 ./ext/cargo-vendor/rb-sys-build-0.9.82/src/rb_config/search_path.rs