gpt4 book ai didi

rust - 打印!宏被乱序执行

转载 作者:行者123 更新时间:2023-11-29 08:02:27 25 4
gpt4 key购买 nike

<分区>

我的部分代码如下所示:

print_usage_instructions();
print!("Command: ");
let stdin = io::stdin();
let mut line = String::new();
stdin.lock().read_line(&mut line).expect("Couldn't process the command.");
println!("{}", line);

我期望的行为是这样的:

Usage instructions and stuff
Command: [my command]
[my command]

然而,发生的事情是这样的:

Usage instructions and stuff
[my command]
Command: [my command]

知道为什么会这样吗? AFAIK,编译器没有理由在这里更改执行顺序,这部分代码不是异步的也不是多线程的。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com