path.clear();
_ = write!(&mut path, "assets/{name}.json", name = en.name);
let content = io::read(&path);
let sockets = io::parse_json(&path, &content);
Tile {
im: &en.im,
sockets,
}
};
то
error: lifetime may not live long enough
--> src/asset.rs:28:9
|
22 | let tile = |en: &Entry| {
| - - return type of closure is Tile<'2>
| |
| let's call the lifetime of this reference `'1`
...
28 | / Tile {
29 | | im: &en.im,
30 | | sockets,
31 | | }
| |_________^ returning this value requires that `'1` must outlive `'2`
НО 🤯
let tile = |en| {
let en: &Entry = en; // WTF?
path.clear();
_ = write!(&mut path, "assets/{name}.json", name = en.name);
let content = io::read(&path);
let sockets = io::parse_json(&path, &content);
Tile {
im: &en.im,
sockets,
}
};
Так код собирается... 💀
Больше похоже на баг компиляхтора
Обсуждают сегодня