basic/result-error/panic #755
Replies: 13 comments 8 replies
-
Panic是真的难。。。。。。看了三遍都不太懂 |
Beta Was this translation helpful? Give feedback.
-
感谢panic 原理剖析,讲得很清晰;之前debug看到在main函数调用前也做了catch_unwind,看到这里终于懂了 |
Beta Was this translation helpful? Give feedback.
-
前端转rust第二天 |
Beta Was this translation helpful? Give feedback.
-
原理剖析得有个例子额 |
Beta Was this translation helpful? Give feedback.
-
这panic功能太扯了。报个小错就退出程序。 |
Beta Was this translation helpful? Give feedback.
-
原理剖析看不懂 /(ㄒoㄒ)/~~ |
Beta Was this translation helpful? Give feedback.
-
这个原理剖析是不是要加一下版本? |
Beta Was this translation helpful? Give feedback.
-
在软件工程实践中,架构对于异常处理也很重要。比如ui模块,io模块,都是对容错要求极高的。而logic模块则对容错要求低一些,毕竟这部分是可以通过unittest实现边界条件全覆盖的。 |
Beta Was this translation helpful? Give feedback.
-
读后感: panic! 和 unwrap() 还是忘记它吧! |
Beta Was this translation helpful? Give feedback.
-
rust吸收了好多语言的特性,设计巧妙 |
Beta Was this translation helpful? Give feedback.
-
在 Rust 中,如果你在一个子线程中触发了 panic,这个子线程会终止,但这不会直接影响主线程或其他子线程的运行,除非你显式地检测并对其做出响应。以下是一个示例,其中子线程中发生了 panic,但主线程仍然继续执行: use std::thread;
fn main() {
// 创建一个子线程
let handle = thread::spawn(|| {
// 这里模拟子线程中发生了某种错误,触发 panic
panic!("Something went wrong in the thread!");
});
// 等待子线程结束
let result = handle.join();
// 检查子线程的结果
match result {
Ok(_) => println!("Thread completed successfully."),
Err(e) => println!("Thread panicked with error: {:?}", e),
}
// 主线程继续执行
println!("Continuing execution in main thread.");
} 在这个示例中:
这样的处理使得程序可以在子线程遇到致命错误时保持健壮性,不会被一个子线程的失败拖垮整个程序。 |
Beta Was this translation helpful? Give feedback.
-
panic后会发送信号吗, 设置的panic = "abort" |
Beta Was this translation helpful? Give feedback.
-
感觉生命周期才是最绕的目前 |
Beta Was this translation helpful? Give feedback.
-
basic/result-error/panic
https://course.rs/basic/result-error/panic.html
Beta Was this translation helpful? Give feedback.
All reactions