-
Notifications
You must be signed in to change notification settings - Fork 51
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
Hrp
should have a constructor from a T: Display
#195
Comments
How would such a constructor get at the string (bytes) created by the We could add convenience constructors but I don't really see the value, what am I missunderstanding? /// Constructs a `Hrp` for an `hrp` string created by calling `hrp.to_string()`.
pub fn from_display(hrp: impl fmt::Display) -> Result<Self, Error> {
let s = hrp.to_string();
Self::parse(&s)
}
/// Constructs a `Hrp` for an `hrp` string created by calling `hrp.to_string()`.
pub fn from_display_unchecked(hrp: impl fmt::Display) -> Self {
let s = hrp.to_string();
Self::parse_unchecked(&s)
} |
By implementing a |
apoelstra
added a commit
to apoelstra/rust-bech32
that referenced
this issue
Aug 6, 2024
apoelstra
added a commit
to apoelstra/rust-bech32
that referenced
this issue
Aug 6, 2024
Concept ACK, and cool implementation in #196 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This would allow easy construction from a rust-lightning
RawHrp
. Currently it allocates aString
which is an unnecessary allocation and inconvenient.The text was updated successfully, but these errors were encountered: