These are chat archives for rust-lang/rust

13th
Dec 2018
Roman Proskuryakov
@kpp
Dec 13 2018 05:50
Hello. I need to call sodium_init (doc: sodium_init() should be called before any other functions.) before any test. Is there is a solution for that instead of putting sodium_init in the every #[test] fn?
Tim Robinson
@1tgr
Dec 13 2018 07:07
If I was writing Rust code that wraps libsodium I would put a call to sodium_init() in the fn new() of any type that uses libsodium
Roman Proskuryakov
@kpp
Dec 13 2018 07:10
well, I need 1 call in fn main in binary app. I don't need to spread it all around the project
The reason I am asking is that there is a lot of usecases for that
Sylwester Rąpała
@xoac
Dec 13 2018 10:09

Hi, I would like this nice future_retry
any idea how to achieve this? In examples there are only when I don't need to specify inner types.

// my struct where I want hold FutureRetry
  pub struct ReadResponse {
      temp_res: FutureRetry<ReadPartFactoryType, ReadPartErrorHandlerType>,
}
// types for Futures Retry
  type ReadPartFactoryType = fn() -> MtcpReadResponse;
  type ReadPartErrorHandlerType = fn(Error) -> RetryPolicy<Error>;

// funtion I will pass to FutreRetry::new() to decide when retry
fn error_handler(err: Error) -> RetryPolicy<Error>;

// place where I am creating new FutureRetry and get error
>>            self.temp_res = FutureRetry::new(move || self.req_builder.clone().read_req(&self.next_part_request()), error_handler);

error:

error[E0308]: mismatched types                                                                                                                                                                                                               
   --> src/client/mod.rs:302:46                                                                                                                                                                                                              
    |                                                                                                                                                                                                                                        
302 |             self.temp_res = FutureRetry::new(move || self.req_builder.clone().read_req(&self.next_part_request()), error_handler);                                                                                                     
    |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure                                                                                   
    |                                                                                                                                                                                                                                        
    = note: expected type `fn() -> mtcp_client::client::ReadResponse`                                                                                                                                                                        
               found type `[closure@src/client/mod.rs:302:46: 302:114 self:_]`
Achala_Bhatt
@AchalaSB
Dec 13 2018 10:39
Hi. Anyone hlp me to fix this issue
error[E0463]: can't find crate for `chisel`
 --> src/lib.rs:2:1
  |
2 | extern crate chisel;
  | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
I tried all these 3 cases to addchisel in my Cargo.toml but everytime when I run cargo build I got same eror
[dependencies]
chisel ={ git = "https://github.com/wasmx/wasm-chisel"}
chisel = "0.1.0"
chisel = {path = "../chisel"}
Sylwester Rąpała
@xoac
Dec 13 2018 10:54
chisel is binary not lib
@AchalaSB See https://github.com/wasmx/wasm-chisel/tree/master/chisel/src there is no lib.rs in this folder. If u want to run this application you need to clone it and run cargo build in this cloned directory.
Achala_Bhatt
@AchalaSB
Dec 13 2018 10:57
@xoac lib.rs is my code file in thatt I have mentioned export crate chisel
Sylwester Rąpała
@xoac
Dec 13 2018 10:59
@AchalaSB I see. But chisel has no lib.rs so it can be used as a create because sb who create it dosen't provide this functionality. Your code would work if chisel would have lib.rs
Sylwester Rąpała
@xoac
Dec 13 2018 11:05
I found solution for my problem with FutureRetry. Use struct instead of function and implement FutureFactory trait for it. Just still problem with error handler :(
error[E0308]: mismatched types                                                                                                                                                                                                               
   --> src/client/mod.rs:294:13                                                                                                                                                                                                              
    |                                                                                                                                                                                                                                        
294 |             temp_res,                                                                                                                                                                                                                  
    |             ^^^^^^^^ expected fn pointer, found fn item                                                                                                                                                                                
    |                                                                                                                                                                                                                                        
    = note: expected type `futures_retry::FutureRetry<_, fn(mtcp_client::error::Error) -> futures_retry::RetryPolicy<mtcp_client::error::Error>>`                                                                                            
               found type `futures_retry::FutureRetry<_, fn(mtcp_client::error::Error) -> futures_retry::RetryPolicy<mtcp_client::error::Error> {client::error_handler}>`
Daniel Bischof
@dbischof90
Dec 13 2018 16:46
Hey, I'm trying to install RLS right now but for some reason I get an error that 'rls is unavailable for download'. Any hints?
Daniel Bischof
@dbischof90
Dec 13 2018 17:00
Okay, choosing beta toolchain works