-
Notifications
You must be signed in to change notification settings - Fork 24
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
Truncating behavior is confusing and forces allocations #77
Comments
Agreed. Should be a pretty easy change and I think worth a breaking release. |
Would you expect the same when decoding into a #[test]
fn append() {
let mut buf = b"hello world".to_owned();
bs58::decode("a").into(&mut buf).unwrap();
assert_eq!(b"hello world!", buf.as_ref());
}
#[test]
fn no_append() {
let mut buf = b"hello world".to_owned();
bs58::decode("a").into(buf.as_mut()).unwrap();
assert_eq!(b"!ello world", buf.as_ref());
} |
For For |
Returning an |
Hm, I think base58 guarantees that the encoded result is utf8, so no additional validation is necessary? If this assumption is correct, that returning |
Yeah, it wouldn't need validating since the API guarantees it's ASCII, but I want to minimize the unsafe code here (currently the only unsafe code used is the bare minimum necessary to actually work with |
I expect the following test to pass:
Instead, it fails, as the
buf
contains just"2b"
. That is, encoding discards existing data, rather than appending to it.There are two problems with it:
.clear()
"<algo-name>-<base58 encoded bytes>"
.The text was updated successfully, but these errors were encountered: