From 5343ac039660428d45194a11862463e91e33660a Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Tue, 23 Apr 2019 13:25:38 -0400 Subject: [PATCH] Make sure the unit struct actually compiles --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5c4f35f..ff8341a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ use std::io; +use std::marker::PhantomData; #[derive(Debug)] pub enum KError<'a> { @@ -28,14 +29,17 @@ pub trait KStruct<'a> { fn read(&mut self, stream: &mut S) -> KResult<'a, ()>; } -pub struct KStructUnit<'a>; +#[derive(Debug, Default, Copy, Clone)] +pub struct KStructUnit<'a> { + phantom: PhantomData<&'a ()> +} impl<'a> KStruct<'a> for KStructUnit<'a> { type Parent = KStructUnit<'a>; type Root = KStructUnit<'a>; fn new(_parent: Option<&'a Self::Parent>, _root: Option<&'a Self::Root>) -> Result> where Self: Sized { - Ok(KStructUnit) + Ok(KStructUnit { phantom: PhantomData }) } fn read(&mut self, stream: &mut S) -> Result<(), KError<'a>> {