suharev7 / clickhouse-rs

Asynchronous ClickHouse client library for Rust programming language.
MIT License
324 stars 121 forks source link

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

Open bnaecker opened 3 years ago

bnaecker commented 3 years ago

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.