use super::context::BindgenContext;
use std::cmp;
use std::ops;
pub trait CanDeriveDebug {
fn can_derive_debug(&self, ctx: &BindgenContext) -> bool;
}
pub trait CanDeriveCopy {
fn can_derive_copy(&self, ctx: &BindgenContext) -> bool;
}
pub trait CanDeriveDefault {
fn can_derive_default(&self, ctx: &BindgenContext) -> bool;
}
pub trait CanDeriveHash {
fn can_derive_hash(&self, ctx: &BindgenContext) -> bool;
}
pub trait CanDerivePartialEq {
fn can_derive_partialeq(&self, ctx: &BindgenContext) -> bool;
}
pub trait CanDerivePartialOrd {
fn can_derive_partialord(&self, ctx: &BindgenContext) -> bool;
}
pub trait CanDeriveEq {
fn can_derive_eq(&self, ctx: &BindgenContext) -> bool;
}
pub trait CanDeriveOrd {
fn can_derive_ord(&self, ctx: &BindgenContext) -> bool;
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum CanDerive {
Yes,
Manually,
No,
}
impl Default for CanDerive {
fn default() -> CanDerive {
CanDerive::Yes
}
}
impl CanDerive {
pub fn join(self, rhs: Self) -> Self {
cmp::max(self, rhs)
}
}
impl ops::BitOr for CanDerive {
type Output = Self;
fn bitor(self, rhs: Self) -> Self::Output {
self.join(rhs)
}
}
impl ops::BitOrAssign for CanDerive {
fn bitor_assign(&mut self, rhs: Self) {
*self = self.join(rhs)
}
}