mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-28 01:41:05 +00:00
27 lines
508 B
Rust
27 lines
508 B
Rust
use proc_macro2::Ident;
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
pub enum Derive {
|
|
Clone,
|
|
Copy,
|
|
}
|
|
|
|
impl Derive {
|
|
pub fn from(ident: &Ident) -> Option<Self> {
|
|
match ident.to_string().as_str() {
|
|
"Clone" => Some(Derive::Clone),
|
|
"Copy" => Some(Derive::Copy),
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl AsRef<str> for Derive {
|
|
fn as_ref(&self) -> &str {
|
|
match self {
|
|
Derive::Clone => "Clone",
|
|
Derive::Copy => "Copy",
|
|
}
|
|
}
|
|
}
|