Diffstat (limited to 'src/build/builders/owned.rs')
| -rw-r--r-- | src/build/builders/owned.rs | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/build/builders/owned.rs b/src/build/builders/owned.rs deleted file mode 100644 index 29098c8..0000000 --- a/src/build/builders/owned.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::{build::protocols, implementer, protocol::ImplementerExt, walk, Builder}; - -use super::IncompleteValue; - -pub struct OwnedBuilder<T> { - value: Option<T>, -} - -impl<T> Default for OwnedBuilder<T> { - fn default() -> Self { - Self { value: None } - } -} - -impl<'ctx, T: 'static> Builder<'ctx> for OwnedBuilder<T> { - type Error = IncompleteValue; - - type Value = T; - - fn as_visitor(&mut self) -> &mut dyn crate::protocol::Implementer<'ctx> { - self - } - - fn build(self) -> Result<Self::Value, Self::Error> { - self.value.ok_or(IncompleteValue) - } -} - -implementer! { - impl['ctx, T: 'static] OwnedBuilder<T> = [ - protocols::owned::Owned<T>, - protocols::hint::RequestHint, - ]; -} - -impl<'ctx, T: 'static> protocols::hint::RequestHintObject<'ctx> for OwnedBuilder<T> { - fn request_hint( - &mut self, - hints: &mut dyn crate::protocol::Implementer<'ctx>, - ) -> Result<(), ()> { - if let Some(interface) = - hints.interface_for::<walk::protocols::hint::Hint<protocols::owned::Owned<T>>>() - { - interface.as_object().hint(self, ()) - } else { - Ok(()) - } - } -} - -impl<'ctx, T: 'static> protocols::owned::Object<'ctx, T> for OwnedBuilder<T> { - fn visit(&mut self, value: T) -> Result<(), ()> { - self.value = Some(value); - Ok(()) - } -} |