saikrishna1-bidgely commented on PR #4908:
URL: 
https://github.com/apache/arrow-datafusion/pull/4908#issuecomment-1398775889

   @alamb I finally got a way to implement overloading using Traits.
   ```rust
   use std::vec;
   
   fn main() {
       struct PATH {
       }
       
       impl PATH {
           pub fn new() -> Self {
               Self {
               }
           }
       }
       
       pub trait Reader<T>: Sized {
           fn read_csv(&self, value: T) -> i32;
       }
       
       impl<'a> Reader<&'a str> for PATH {
           fn read_csv(&self, p: &'a str) -> i32  {
               self.read_csv(vec![p])
           }
       }
       
       impl<'a> Reader<Vec<&'a str>> for PATH {
           fn read_csv(&self, v: Vec<&'a str>) -> i32 {
               v.len() as i32
           }
       }
       let p = PATH::new();
       println!("{:?}", p.read_csv("path"));
       println!("{:?}", p.read_csv(vec!["path", "paths2"]));
   }
   ```
   This way, callees using `str` or `String` can continue using the function 
and we can add support for vector/iterators. I will write a more general 
solution for read functions.
   
   I tried to implement using Enum and Union but I wasn't able to do so and 
they will change the function signature.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to