extern crate ketos; #[macro_use] extern crate ketos_derive; use std::fmt; use ketos::{FromValue, FromValueRef, Value}; #[derive(Debug, ForeignValue, FromValue, FromValueRef, IntoValue)] struct NoClone(&'static str); #[derive(Clone, Debug, ForeignValue, FromValueClone, FromValueRef, IntoValue)] struct Cloner(&'static str); #[test] fn test_derive() { let a: Value = NoClone("foo").into(); let b = a.clone(); assert!(<&NoClone>::from_value_ref(&a).is_ok()); assert!(NoClone::from_value(a).is_err()); assert!(NoClone::from_value(b).is_ok()); let a: Value = Cloner("foo").into(); let b = a.clone(); assert!(<&Cloner>::from_value_ref(&a).is_ok()); assert!(Cloner::from_value(a).is_ok()); assert!(Cloner::from_value(b).is_ok()); } #[derive(ForeignValue, FromValue, FromValueRef, IntoValue)] struct Generic(T); impl fmt::Debug for Generic { fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { unimplemented!() } } #[derive(ForeignValue, FromValue, FromValueRef, IntoValue)] struct GenericWhere(T) where T: 'static; impl fmt::Debug for GenericWhere { fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { unimplemented!() } } #[derive(ForeignValue, FromValueClone, FromValueRef, IntoValue)] struct CloneGeneric(T); impl Clone for CloneGeneric { fn clone(&self) -> Self { unimplemented!() } } impl fmt::Debug for CloneGeneric { fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { unimplemented!() } } #[derive(ForeignValue, FromValueClone, FromValueRef, IntoValue)] struct CloneGenericWhere(T) where T: 'static; impl Clone for CloneGenericWhere { fn clone(&self) -> Self { unimplemented!() } } impl fmt::Debug for CloneGenericWhere { fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { unimplemented!() } }