clickhouse-rs icon indicating copy to clipboard operation
clickhouse-rs copied to clipboard

Implement `TryFrom` rather than `From` for fallible conversions

Open bnaecker opened this issue 4 years ago • 0 comments

This crate provides methods for converting from the Value enum into many native Rust types. These conversions are generally done these with the From trait, for example From<Value> for u64. However, such conversions are not infallible. Instead, should the Value variant not be convertible to T, the crate chooses to panic. The preferred approach in this case is to use TryFrom, which allows the crate's consumer to decide how to handle failures.

I'm happy to help add the relevant TryFrom implementations, but I would defer to the author as to how to handle the existing From implementations.

bnaecker avatar May 20 '21 23:05 bnaecker