tor-cell: Assert data length in Data cells

This commit adds a `debug_assert!` macro into the `new_unchecked()`
function of the Data cell. Beside this, it also fixes a misleading
comment regarding that limit.
This commit is contained in:
Emil Engler 2022-10-24 13:33:24 +02:00
parent b031616b5f
commit fb2195b0cf
No known key found for this signature in database
GPG Key ID: 2F6D4145C55FC7C7
1 changed files with 2 additions and 1 deletions

View File

@ -399,8 +399,9 @@ impl Data {
/// Construct a new data cell from a provided vector of bytes.
///
/// The vector _must_ have fewer than [`Data::MAXLEN`] bytes.
/// The vector _must_ not have more than [`Data::MAXLEN`] bytes.
fn new_unchecked(body: Vec<u8>) -> Self {
debug_assert!(body.len() <= Data::MAXLEN);
Data { body }
}
}