【发布时间】:2020-01-07 00:16:21
【问题描述】:
我正在使用 winapi crate 从 Rust 调用 ResumeThread WinAPI 函数。
文档说:
如果函数成功,则返回值是线程之前的挂起计数。
如果函数失败,返回值为(DWORD)-1。
如何有效检查是否有错误?
在 C 中:
if (ResumeThread(hMyThread) == (DWORD) -1) {
// There was an error....
}
在锈中:
unsafe {
if ResumeThread(my_thread) == -1 {
// There was an error....
}
}
the trait `std::ops::Neg` is not implemented for `u32`
我理解错误;但是在语义上与 C 代码相同的最佳方式是什么?检查std::u32::MAX?
【问题讨论】:
标签: rust ffi signedness