/
View dependency graph
Depends on
- dh-rust (dh-sequence-rust)
- debhelper-compat
README (full)
as_variant
A simple Rust macro to convert enums with newtype variants to Options.
Basic example:
use std::ops::Deref;
use as_variant::as_variant;
enum Value {
Integer(i64),
String(String),
Array(Vec<Value>),
}
impl Value {
pub fn as_integer(&self) -> Option<i64> {
as_variant!(self, Self::Integer).copied()
}
pub fn as_str(&self) -> Option<&str> {
as_variant!(self, Self::String).map(Deref::deref)
}
pub fn as_array(&self) -> Option<&[Value]> {
as_variant!(self, Self::Array).map(Deref::deref)
}
pub fn into_string(self) -> Option<String> {
as_variant!(self, Self::String)
}
pub fn into_array(self) -> Option<Vec<Value>> {
as_variant!(self, Self::Array)
}
}
| dir | debian/ |
| dir | src/ |
| file | .gitignore |
| file | .rustfmt.toml |
| file | Cargo.toml |
| file | LICENSE |
| file | README.md |