我正在尝试实现Serialize外部Deserialize枚举,但我不知道如何实现。它有From<u64>所以我想做的只是让该对象序列化。
#[derive(Serialize, Deserialize)]
pub struct ImageBinds {
binds: HashMap<KeybdKey, Vec<u8>>, // KeybdKey doesn't implement serialize
}
// won't compile with this:
// only traits defined in the current crate can be implemented for arbitrary types
// impl doesn't use only types from inside the current crate
// I understand the orphan rule and all that but I have no idea how else I'd implement it
// I've looked at serde remote stuff and I …Run Code Online (Sandbox Code Playgroud) 我开始遵循这个关于如何在 bevy 中制作游戏的教程。代码编译得很好,但仍然很慢(老实说,我不确定这是否正常,大约需要 8 秒),但是当我启动游戏时,窗口会变白 ( )Not Responding几秒钟(大约相同的时间)正确加载之前的时间(作为编译时间,可能稍微少一点)。
这是我的Cargo.toml:
[package]
name = "rustship"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = "0.8.1"
# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3
[workspace]
resolver = "2"
Run Code Online (Sandbox Code Playgroud)
我尝试了使用和不使用工作区解析器的情况。我的 rustup 工具链是nightly-x86_64-pc-windows-gnu,我用它rust-lld来链接程序:
[target.nightly-x86_64-pc-windows-gnu]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=n"]
Run Code Online (Sandbox Code Playgroud)
根据官方的 …