-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed Default
from SerializedSignature
#458
Merged
apoelstra
merged 1 commit into
rust-bitcoin:master
from
Kixunil:remove_serialized_signature_default
Jun 22, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,16 +35,6 @@ impl fmt::Display for SerializedSignature { | |
} | ||
} | ||
|
||
impl Default for SerializedSignature { | ||
#[inline] | ||
fn default() -> SerializedSignature { | ||
SerializedSignature { | ||
data: [0u8; MAX_LEN], | ||
len: 0, | ||
} | ||
} | ||
} | ||
|
||
impl PartialEq for SerializedSignature { | ||
#[inline] | ||
fn eq(&self, other: &SerializedSignature) -> bool { | ||
|
@@ -91,10 +81,18 @@ impl<'a> IntoIterator for &'a SerializedSignature { | |
} | ||
|
||
impl SerializedSignature { | ||
/// Get a pointer to the underlying data with the specified capacity. | ||
/// Creates `SerializedSignature` from data and length. | ||
/// | ||
/// ## Panics | ||
/// | ||
/// If `len` > `MAX_LEN` | ||
#[inline] | ||
pub(crate) fn get_data_mut_ptr(&mut self) -> *mut u8 { | ||
self.data.as_mut_ptr() | ||
pub(crate) fn from_raw_parts(data: [u8; MAX_LEN], len: usize) -> Self { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have |
||
assert!(len <= MAX_LEN, "attempt to set length to {} but the maximum is {}", len, MAX_LEN); | ||
SerializedSignature { | ||
data, | ||
len, | ||
} | ||
} | ||
|
||
/// Get the capacity of the underlying data buffer. | ||
|
@@ -111,7 +109,7 @@ impl SerializedSignature { | |
|
||
/// Set the length of the object. | ||
#[inline] | ||
pub(crate) fn set_len(&mut self, len: usize) { | ||
pub(crate) fn set_len_unchecked(&mut self, len: usize) { | ||
self.len = len; | ||
} | ||
|
||
|
@@ -218,7 +216,7 @@ mod into_iter { | |
// reach this | ||
let new_len = self.signature.len() - 1; | ||
let byte = self.signature[new_len]; | ||
self.signature.set_len(new_len); | ||
self.signature.set_len_unchecked(new_len); | ||
Some(byte) | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic style question I've been wondering about, if you have an opinion please. Since I started writing docs like these I've switched from using the format above to using no space after the heading when it looks 'spacey' (lots of whitespace). But its leading to non-uniform docs because once there is more text it looks better with the space. Do you have an opinion?
Without the space kinda looks nicer
And a made up more wordy one with the newline seems to look nicer.
Should we favor dogmatic uniformity (my go to :), or go with different newline spacing depending on the situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to always have empty line after heading. I think changing this one would be just noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm going to follow suit. I'll change any I come across that I wrote the other way :) Cheers.