Created
March 3, 2017 23:09
-
-
Save U007D/e0262da545c59ddf949eb70164edc3d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Transform iterable collection of Strings to iterable collection of &str and pass to libMain() | |
fn main() { | |
xargo_lld_wrapper::libMain(std::env::args().map(|el| el.as_str()).collect::<Vec<_>>()); | |
} | |
-- | |
/Users/bRad/.cargo/bin/cargo test --color=always -- --nocapture | |
Compiling xargo-lld-wrapper v0.1.0 (file:///Users/bRad/Development/bg/experiments/rust/rpi3/xargo-lld-wrapper) | |
error: `el` does not live long enough | |
--> src/main.rs:4:68 | |
| | |
4 | xargo_lld_wrapper::libMain(std::env::args().map(|el| el.as_str()).collect::<Vec<_>>()); | |
| -- ^ - borrowed value needs to live until here | |
| | | | |
| | `el` dropped here while still borrowed | |
| borrow occurs here | |
error: aborting due to previous error | |
error: Could not compile `xargo-lld-wrapper`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let strings = vec!["string1".to_string(), "string2".to_string(), "string3".to_string()]; | |
let strs = strings.iter().map(|el| el.as_str()).collect::<Vec<_>>(); //lifetime violation (el), but not really (strings) | |
let () = strs[1]; | |
println!("{:?}", strs); | |
} | |
-- | |
rustc 1.15.1 (021bd294c 2017-02-08) | |
["string1", "string2", "string3"] | |
Program ended. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
xargo_lld_wrapper::lib_main(std::env::args().collect::<Vec<_>>() | |
.iter() | |
.map(|el| el.as_str()).collect::<Vec<_>>()); | |
} | |
-- | |
/Users/bRad/.cargo/bin/cargo test --color=always -- --nocapture | |
Compiling xargo-lld-wrapper v0.1.0 (file:///Users/bRad/Development/bg/experiments/rust/rpi3/xargo-lld-wrapper) | |
Finished dev [unoptimized + debuginfo] target(s) in 1.47 secs | |
Running target/debug/deps/xargo_lld_wrapper-dc5583a5b836a9c8 | |
running 1 test | |
test tests::app_call_with_no_params_succeeds ... ok | |
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment