Questions tagged [rust-2018]

Use this tag for code that requires Rust 2018 to compile or questions specifically related to the Rust 2018 edition.

Use this tag for code that requires Rust 2018 to compile or questions specifically related to the Rust 2018 edition.

For documentation about Rust editions, see the Edition Guide

13 questions
26
votes
2 answers

How to idiomatically alias a crate in Rust 2018?

I have a crate foo_sys. In Rust 2015 I used extern crate foo_sys as foo for convenience, but in Rust 2018 extern crate isn't needed anymore and I don't want to use it only for aliasing. When dropping extern crate, I get error[E0463]: can't find…
Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
15
votes
3 answers

How do I resolve the error "no module in the root" when using a module in Rust 2018?

I'm working on a project that is utilizing some local modules in folders under src/. I'm currently using Rust 2018 edition and one of the major changes for that is the handling of imports/use statements. My module code is all working correctly, but…
RPiAwesomeness
  • 5,009
  • 10
  • 34
  • 52
9
votes
2 answers

How to import all macros, derives, and procedural macros in Rust 2018 without using extern crate?

I'm experimenting with Rust Edition 2018. In Rust 2015 you use #[macro_use] extern crate log; for importing macros. In Rust 2018 extern crate is probably unidiomatic. Is there a way, to import all macros from the crate without extern crate? For…
Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
8
votes
1 answer

Why does my trait definition compile with the 2015 edition but not with the 2018 edition?

I wrote this simple program: trait Command { fn execute(&self, &mut T); …
T.Shin
  • 103
  • 7
5
votes
2 answers

What are the use cases of raw identifiers besides new keywords?

As in Rust 2018, we now have raw identifiers: This feature is useful for a few reasons, but the primary motivation was inter-edition situations. For example, try is not a keyword in the 2015 edition, but is in the 2018 edition. So if you have a…
Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
4
votes
2 answers

Can Rust macros be shared across editions?

Say a Rust 2018 macro defines an async function inside it. The syntax it would use would be incompatible with Rust 2015. So if you're compiling your crate with 2015 edition, wouldn't this expanded code from the macro conflict with that? I'm not that…
zombiesauce
  • 1,009
  • 1
  • 7
  • 22
4
votes
1 answer

Attempting to import `reqwest::async` errors stating that `async` is a reserved keyword

I want to make asynchronous HTTP requests using the reqwest crate. I have the following code: // see https://docs.rs/reqwest/*/reqwest/async/index.html use reqwest::async::Client; When I attempt to compile my code I get the following error: error:…
taryn
  • 581
  • 8
  • 18
3
votes
0 answers

How to execute a command which ask for input in Rust

I am building a CLI using Rust-2018. It's a kind of wrapper around an old command. I need to call that command in my Rust program but the thing is that the command asks for input (password) to perform the task. Just like keytool when to need to…
Hve
  • 75
  • 5
3
votes
2 answers

What are the valid path roots in the use keyword?

With the module system being revamped for the 2018 edition, the functioning of the use keyword has changed. What are the valid paths that can go after the use keyword?
Boiethios
  • 38,438
  • 19
  • 134
  • 183
1
vote
1 answer

Check if a file is a symlink in Rust 2018 on Windows

I'm writing a small utility for myself that needs to be able to check if a file is a symlink or not. Using FileType::is_symlink on Windows always returns false (goes for both symlinks to directories, and regular files). Using regular Rust 2018…
LaVache
  • 2,372
  • 3
  • 24
  • 38
1
vote
2 answers

lifetime around async and stream

I am trying to make a function that consumes Stream and truncate it when there are max_consecutive_fails consecutive fails. However, things didn't work well(E0495). I changed Streams to Iterators (and removed asyncs) and it simply worked. Why does…
Lee SongUn
  • 55
  • 6
0
votes
1 answer

How to convert the inner value in an Option?

I have an Option that contains some JSON. If it is Some, the inner JSON must be converted, but if it is None, it must remain None. This is how I have this implemented currently: struct One; struct Other; impl One { pub fn convert(&self) ->…
berkes
  • 26,996
  • 27
  • 115
  • 206
0
votes
1 answer

Way to get current edition in build script?

Is it possible to read the currently used Rust edition in a build script? Maybe through an environment variable? I tried EDITION and CARGO_EDITION, but it didn't work. I didn't find any documentation on this either.
Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69