]> git.bitcoin.ninja Git - rust-lightning/commitdiff
`rustfmt`: Prepare `lightning-invoice/src/de.rs`
authorElias Rohrer <dev@tnull.de>
Thu, 14 Nov 2024 10:45:45 +0000 (11:45 +0100)
committerElias Rohrer <dev@tnull.de>
Thu, 14 Nov 2024 10:45:45 +0000 (11:45 +0100)
lightning-invoice/src/de.rs

index da43edc5b6b65dd91644a72dad5a0db921a37dfe..8e06f326ccd46b54c31395fb9bed5898d7425215 100644 (file)
@@ -446,12 +446,13 @@ impl FromBase32 for RawDataPart {
        type Err = Bolt11ParseError;
 
        fn from_base32(data: &[Fe32]) -> Result<Self, Self::Err> {
-               if data.len() < 7 { // timestamp length
+               const TIMESTAMP_LEN: usize = 7;
+               if data.len() < TIMESTAMP_LEN {
                        return Err(Bolt11ParseError::TooShortDataPart);
                }
 
-               let timestamp = PositiveTimestamp::from_base32(&data[0..7])?;
-               let tagged = parse_tagged_parts(&data[7..])?;
+               let timestamp = PositiveTimestamp::from_base32(&data[0..TIMESTAMP_LEN])?;
+               let tagged = parse_tagged_parts(&data[TIMESTAMP_LEN..])?;
 
                Ok(RawDataPart {
                        timestamp,