-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a std macro_rules path! #12904
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Comments
I'm not sure if there's enough of a use case for this to be added to libstd. You can always define it yourself: macro_rules! path(
($($t:tt),+) => (&Path::new(format!($($t),+)))
) |
This is convenient #[crate_id="abc"];
#[crate_type="bin"];
#[feature(macro_rules)];
#[macro_export]
macro_rules! path(
($e:expr) => (&Path::new($e));
($($arg:tt),+) => (
&Path::new(format_args!(::std::fmt::format, $($arg),+ ))
)
)
fn main(){
use std::io::{File,Open,ReadWrite};
for num in range(0,10){
let p = path!("message{}.txt",num);
println!("write file {}", "message" + num.to_str() + ".txt" );
let mut file = match File::open_mode( p, Open,ReadWrite ){
Ok(o) => o,
Err(e) => fail!("can't open file")
};
file.write_line( "one line" );
}
}
|
Closing for reasons found here: #12915 (comment) |
matthiaskrgr
pushed a commit
to matthiaskrgr/rust
that referenced
this issue
Aug 2, 2022
…lnicola internal: Be more explicit when filtering built-in completions We return every built-in type here, but only have `u32` in the tests, so let's look for that one to make tests more reliable across platforms.
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Jun 13, 2024
Normalize type aliases when checking significant drops. fixes rust-lang#10750 No test as I'm not sure exactly how the type alias caused a stack overflow here. Also removes an unnecessary `HashSet`. changelog: none
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can add a std macro_rules path to mod "std::macros" ,like
=>
The text was updated successfully, but these errors were encountered: