Skip to content
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

Conversation

Kixunil
Copy link
Collaborator

@Kixunil Kixunil commented Jun 21, 2022

Default was pointless, so it was replaced with internal
from_raw_parts method which also checks the length.

This commit also documents changes to SerializedSignature.

Closes #454

`Default` was pointless, so it was replaced with internal
`from_raw_parts` method which also checks the length.

This commit also documents changes to `SerializedSignature`.

Closes rust-bitcoin#454
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK b18f5d0

Comment on lines +84 to +88
/// Creates `SerializedSignature` from data and length.
///
/// ## Panics
///
/// If `len` > `MAX_LEN`
Copy link
Member

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

    /// Creates `SerializedSignature` from data and length.
    ///
    /// ## Panics
    /// If `len` > `MAX_LEN`

And a made up more wordy one with the newline seems to look nicer.

    /// Creates `SerializedSignature` from data and length.
    ///
    /// Once there is a long description that takes up a bunch of space saotnhsoaetsaotus s ossao
    /// and goes onto a second line stnaho osanteusoan soa esnthaosu .
    ///
    /// ## Panics
    ///
    /// If `len` > `MAX_LEN`

Should we favor dogmatic uniformity (my go to :), or go with different newline spacing depending on the situation?

Copy link
Collaborator Author

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.

Copy link
Member

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.

#[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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have #[track_caller] in MSRV 1.46

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b18f5d0

@apoelstra apoelstra merged commit 568f16a into rust-bitcoin:master Jun 22, 2022
@Kixunil Kixunil deleted the remove_serialized_signature_default branch June 22, 2022 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

impl Default for SerializedSignature doesn't seem to make sense
3 participants