Skip to content
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

ak_Macros #124503

Closed
wants to merge 2 commits into from
Closed

ak_Macros #124503

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/ui/macros/macro-backtrace-input_prompt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[macro_export]
macro_rules! input_prompt {
($prompt:expr) => {{
use std::io::{stdin, stdout, Write};
print!("{}", $prompt);
let _ = stdout().flush();
let mut input = String::new();
stdin().read_line(&mut input).expect("Failed to read input");
input.trim().to_string() // Changed parse() to to_string() to handle strings
}};
}

Check failure on line 11 in tests/ui/macros/macro-backtrace-input_prompt.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

trailing whitespace
fn main (){
let name = input_prompt!("Enter Your Name");
println!("my name is{}",name);
}
28 changes: 28 additions & 0 deletions tests/ui/macros/macro-backtrace-use_loop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
///```
/// ///use_loop macro can create a loop
/// ///this macro take Five values
/// /// 1 - if you want to do event at loop set True else set False
/// /// 2 - start-Number
/// /// 3 - End-Number
/// /// 4 - variable for loop
/// /// 5 - the method
/// /// you should type true at first value to method working
/// /// example
/// use_loop!(true, 0, 100, i, akp!("{}", i));
/// /// dont do this
/// use_loop!(false, 0, 100, i, akp!("{}", i)); /// Syntax Error
/// ```
#[macro_export]
macro_rules! use_loop {
($should_execute:expr, $start_number:expr, $end_number:expr, $theVar:ident, $the_method:expr) => {

Check failure on line 17 in tests/ui/macros/macro-backtrace-use_loop.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
for $theVar in $start_number..$end_number {
if $should_execute {
$the_method;
}
}
};
}

fn main() {
use_loop!(true, 0, 100, i, akp!("{}", i));
}