-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team
Description
Occasionally I find I need to conditionally use
several libraries. For example, to import data structures used in a conditionally compiled function.
#[cfg(debug_assertions)]
use std::slice;
#[cfg(debug_assertions)]
use std::fs::File;
#[cfg(debug_assertions)]
use std::io::prelude::*;
#[cfg(debug_assertions)]
use std::convert::AsRef;
#[cfg(debug_assertions)]
use std::path::Path;
Whereas, I'd like to write:
#[cfg(debug_assertions)] {
use std::slice;
use std::fs::File;
use std::io::prelude::*;
use std::convert::AsRef;
use std::path::Path;
}
This currently gives:
error: expected item after attributes
--> src/lib.rs:53:24
|
53 | #[cfg(debug_assertions)] {
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team