rustonaut / vec1

Rust `Vec<T>` wrapper that gurantees to contain at least 1 element
Apache License 2.0
88 stars 15 forks source link

from_vec: return None #5

Closed grahamc closed 5 years ago

grahamc commented 5 years ago

The previous error case of returning the original Vec makes the API a bit awkward.

Rust's ? operator can't be used without implementing From on a Vec:

Vec1::from_vec(my_vec)?

I can see how this API came to be: by moving the variable in to the function, you can't get it back in the error case. However, because the Vec is empty, there is no reason to want it back anyway.

grahamc commented 5 years ago

6 would work too :P

yannleretaille commented 5 years ago

Did you guys just submit a PR and a corresponding issue within one minute? 😂

grahamc commented 5 years ago

Updated to implement #6's API.

We work together, and were discussing the quirk of the API... and both of us have a bent on contributing to OSS ;)

rustonaut commented 5 years ago

Thanks, I will release a new version soon, through this is a braking change.

So I will go through the API to see if there are any other API improvements.

grahamc commented 5 years ago

Thanks!