From 442b5c4006a3edc4d571ad80938c573ecbef086c Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Tue, 23 Apr 2019 17:46:21 -0400 Subject: [PATCH] Explicit lifetime for `self` Because we give a reference to ourselves out to children as `_parent`, we can't use an anonymous lifetime --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0c1c3d0..6df8948 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,11 +22,13 @@ pub trait KStruct<'a> { /// Create a new instance of this struct; if we are the root node, /// then both `_parent` and `_root` will be `None`. + // `_root` is an Option because we need to create a root in the first place fn new(_parent: Option<&'a Self::Parent>, _root: Option<&'a Self::Root>) -> KResult<'a, Self> where Self: Sized; - fn read(&mut self, stream: &mut S) -> KResult<'a, ()>; + /// Parse this struct (and any children) from the supplied stream + fn read(&'a mut self, stream: &mut S) -> KResult<'a, ()>; } #[derive(Debug, Default, Copy, Clone)]