These are chat archives for rust-lang/rust

15th
Nov 2018
matrixbot
@matrixbot
Nov 15 2018 03:15
bspeice Are you using nightly Rust in the playground?
matrixbot
@matrixbot
Nov 15 2018 04:01
bspeice And are you sure that PinBox is supposed to exist in nightly? I'm admittedly confused now because I can see it in the stable docs but not in the nightly docs
matrixbot
@matrixbot
Nov 15 2018 05:35
bspeice Right, I'm confused right with you. Sorry I don't have a better answer on this one.
hello2dj
@hello2dj
Nov 15 2018 05:36
thanks
Jordi Pinyana
@jordipainan
Nov 15 2018 12:09

Hello !! I'm trying to cross-compile a project on ubuntu in order to run it on a rpi3. And i've got the following error: Compiling rust-crypto v0.2.36
error: failed to run custom build command for openssl-sys v0.9.39
process didn't exit successfully: /home/jordi/Caelum/raspi-api/target/debug/build/openssl-sys-2b71e6cab2b8c344/build-script-main (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=ARM_UNKNOWN_LINUX_GNUEABI_OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=ARM_UNKNOWN_LINUX_GNUEABI_OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=ARM_UNKNOWN_LINUX_GNUEABI_OPENSSL_DIR
cargo:rerun-if-env-changed=OPENSSL_DIR

--- stderr
thread 'main' panicked at 'OpenSSL library directory does not exist: /usr/lib/ssl/lib', /home/jordi/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.39/build/main.rs:60:9
note: Run with RUST_BACKTRACE=1 for a backtrace.

Anyone experimented the same error ? How u solved ? THANK YOU :D
Roman Frołow
@rofrol
Nov 15 2018 13:02
Hello
How to map Vec<u32> into vector of futures and then collect values?
I know there is join_all but it cannot infer type:
        use futures::stream::iter_ok;
        use futures::Stream;
        use futures::future::ok as fut_ok;
        let tasks = vec![fut_ok(1), fut_ok(2), fut_ok(3)];

        println!("{:?}", futures::future::join_all(tasks).wait()?);
370 |         let tasks = vec![fut_ok(1), fut_ok(2), fut_ok(3)];
    |             -----        ^^^^^^ cannot infer type for `E`
    |             |
    |             consider giving `tasks` a type
Alex Helfet
@fluffysquirrels
Nov 15 2018 15:53
future::ok (as fut_ok) is underlined, therefore the best place to start
future::ok's type (docs) is:
pub fn ok<T, E>(t: T) -> FutureResult<T, E>
So E is a type parameter for FutureResult (docs) that cannot be inferred, but E must be the error type for the resulting Future (ref).
Alex Helfet
@fluffysquirrels
Nov 15 2018 15:59
We can supply E by providing type parameters for fut_ok. fut_ok::<u32, ()> works here
hope that helps
Alex Helfet
@fluffysquirrels
Nov 15 2018 16:28
future::ok's doc page includes an example usage that is helpful:
let future_of_1 = ok::<u32, u32>(1);
Tim Robinson
@1tgr
Nov 15 2018 16:35
I guess the choice of error type for ok doesn’t matter, so you could choose ok::<u32, Void> or ok::<u32, !>
Void is a separate crate, ! is not yet stabilized
Alex Helfet
@fluffysquirrels
Nov 15 2018 16:37
For correctness it won't matter, but of course different types will have different sizes that may not be optimised away
Tim Robinson
@1tgr
Nov 15 2018 16:38
Hence picking Void or !, as they are zero-sized types
Alex Helfet
@fluffysquirrels
Nov 15 2018 16:38
sure :)
Tim Robinson
@1tgr
Nov 15 2018 16:38
Another ZST is () but it’s not convertible into Error
Alex Helfet
@fluffysquirrels
Nov 15 2018 16:38
() worked for me, not sure why it wouldn't be convertible
Tim Robinson
@1tgr
Nov 15 2018 16:40
Depends on the context, it’s fine if you never need to convert it Into another error type
Alex Helfet
@fluffysquirrels
Nov 15 2018 16:44

Ah, I see what you mean now.

As you suggest enum Void {} is a very nice option because it has no values and can't be instantiated at all.

Tim Robinson
@1tgr
Nov 15 2018 16:51
Yep, and the void crate has impl Error for Void, so any necessary conversions still work
laurent bernabé
@loloof64
Nov 15 2018 23:36
Hi everyone, what are the best places to learn about Electron development with Rust ?