# HG changeset patch # User Georges Racinet # Date 2023-03-30 10:14:57 # Node ID 7ef51fff2c4f6f7f21bee618ebdcb257d8d4984a # Parent 841b13e6e84c17c9359d0d8d248acea60d76678d rust-revlog: explicit naming for `RevlogEntry` lifetime This matches what has been done in `revlog::changelog::ChangelogRevisionData`, and has the advantage of making things clearer when we introduce other, shorter lived lifetimes. diff --git a/rust/hg-core/src/revlog/mod.rs b/rust/hg-core/src/revlog/mod.rs --- a/rust/hg-core/src/revlog/mod.rs +++ b/rust/hg-core/src/revlog/mod.rs @@ -400,10 +400,10 @@ impl Revlog { /// The revlog entry's bytes and the necessary informations to extract /// the entry's data. #[derive(Clone)] -pub struct RevlogEntry<'a> { - revlog: &'a Revlog, +pub struct RevlogEntry<'revlog> { + revlog: &'revlog Revlog, rev: Revision, - bytes: &'a [u8], + bytes: &'revlog [u8], compressed_len: u32, uncompressed_len: i32, base_rev_or_base_of_delta_chain: Option, @@ -413,7 +413,7 @@ pub struct RevlogEntry<'a> { hash: Node, } -impl<'a> RevlogEntry<'a> { +impl<'revlog> RevlogEntry<'revlog> { pub fn revision(&self) -> Revision { self.rev } @@ -473,7 +473,7 @@ impl<'a> RevlogEntry<'a> { } /// The data for this entry, after resolving deltas if any. - pub fn rawdata(&self) -> Result, HgError> { + pub fn rawdata(&self) -> Result, HgError> { let mut entry = self.clone(); let mut delta_chain = vec![]; @@ -503,8 +503,8 @@ impl<'a> RevlogEntry<'a> { fn check_data( &self, - data: Cow<'a, [u8]>, - ) -> Result, HgError> { + data: Cow<'revlog, [u8]>, + ) -> Result, HgError> { if self.revlog.check_hash( self.p1, self.p2, @@ -525,7 +525,7 @@ impl<'a> RevlogEntry<'a> { } } - pub fn data(&self) -> Result, HgError> { + pub fn data(&self) -> Result, HgError> { let data = self.rawdata()?; if self.is_censored() { return Err(HgError::CensoredNodeError); @@ -535,7 +535,7 @@ impl<'a> RevlogEntry<'a> { /// Extract the data contained in the entry. /// This may be a delta. (See `is_delta`.) - fn data_chunk(&self) -> Result, HgError> { + fn data_chunk(&self) -> Result, HgError> { if self.bytes.is_empty() { return Ok(Cow::Borrowed(&[])); }