green-coder / cdc

A library for performing Content-Defined Chunking (CDC) on data streams.
MIT License
23 stars 5 forks source link

fix compiler errors #7

Open aawsome opened 1 year ago

aawsome commented 1 year ago

Seems the compiler gets stricter about types. I'm getting the following errors when trying to publish my dependent project:

error[E0053]: method `slide` has an incompatible type for trait                                                                                                             
   --> /home/alex-dev/.cargo/registry/src/github.com-1ecc6299db9ec823/cdc-0.1.1/src/rolling_hash.rs:157:31                                                                  
    |                                                                                                                                                                       
157 |     fn slide(&mut self, byte: u8) {                                                                                                                                   
    |                               ^^                                                                                                                                      
    |                               |                                                                                                                                       
    |                               expected `&u8`, found `u8`                                                                                                              
    |                               help: change the parameter type to match the trait: `&u8`                                                                               
    |                                                                                                                                                                       
note: type in trait                                                                                                                                                         
   --> /home/alex-dev/.cargo/registry/src/github.com-1ecc6299db9ec823/cdc-0.1.1/src/rolling_hash.rs:11:31                                                                   
    |                                                                                                                                                                       
11  |     fn slide(&mut self, byte: &u8);                                                                                                                                   
    |                               ^^^                                                                                                                                     
    = note: expected fn pointer `fn(&mut Rabin64, &u8)`                                                                                                                     
               found fn pointer `fn(&mut Rabin64, u8)`

error[E0308]: mismatched types       
   --> /home/alex-dev/.cargo/registry/src/github.com-1ecc6299db9ec823/cdc-0.1.1/src/rolling_hash.rs:111:32
    |                                                                                                                                                                       
111 |                     self.slide(b);
    |                          ----- ^
    |                          |     |                                                                                                                                      
    |                          |     expected `&u8`, found `u8`
    |                          |     help: consider borrowing here: `&b`
    |                          arguments to this function are incorrect
    |                                                                                 
note: associated function defined here                                                
   --> /home/alex-dev/.cargo/registry/src/github.com-1ecc6299db9ec823/cdc-0.1.1/src/rolling_hash.rs:11:8
    |                         
11  |     fn slide(&mut self, byte: &u8);                                                                                                                                   
    |        ^^^^^         

error[E0614]: type `u8` cannot be dereferenced
   --> /home/alex-dev/.cargo/registry/src/github.com-1ecc6299db9ec823/cdc-0.1.1/src/rolling_hash.rs:163:47
    |                                                                                 
163 |         self.window_data[self.window_index] = *byte;
    |                                               ^^^^^

This PR should fix these errors.

green-coder commented 1 year ago

Thank you for the PR, will review when I have time.

aawsome commented 1 year ago

Any updates on this? Actually, it prevents me from releasing my project to crates.io, so I would appreciate to have a solution in near future...

green-coder commented 1 year ago

I am sorry, I am very busy recently and I won't have time to immerse myself into the Rust language until a while.

For now, I suggest you to find an way of using your fork of the library into your project so you don't get stuck.

aawsome commented 1 year ago

Unfortunately, I can't use the fork as dependency as crates.io recommends that all dependencies are also published on crates.io. But I made a PR to integrate (parts of) your code into my project. Have a look at https://github.com/rustic-rs/rustic/pull/401 and please complain if you don't agree with that.