Remove utils::Prefable in favour of guard::Guard

This commit is contained in:
Anthony Ramine 2016-05-20 23:03:14 +02:00
parent a20db08f06
commit fd7c4f8149
5 changed files with 91 additions and 61 deletions

View file

@ -39,7 +39,6 @@ use std::ffi::CString;
use std::os::raw::c_void;
use std::ptr;
use std::slice;
use util::prefs;
/// Proxy handler for a WindowProxy.
pub struct WindowProxyHandler(pub *const libc::c_void);
@ -550,24 +549,3 @@ unsafe extern "C" fn instance_class_has_proto_at_depth(clasp: *const js::jsapi::
pub const DOM_CALLBACKS: DOMCallbacks = DOMCallbacks {
instanceClassMatchesProto: Some(instance_class_has_proto_at_depth),
};
/// A container around JS member specifications that are conditionally enabled.
pub struct Prefable<T: 'static> {
/// If present, the name of the preference used to conditionally enable these specs.
pub pref: Option<&'static str>,
/// The underlying slice of specifications.
pub specs: &'static [T],
}
impl<T> Prefable<T> {
/// Retrieve the slice represented by this container, unless the condition
/// guarding it is false.
pub fn specs(&self) -> Option<&'static [T]> {
if let Some(pref) = self.pref {
if !prefs::get_pref(pref).as_boolean().unwrap_or(false) {
return None;
}
}
Some(self.specs)
}
}