!homDUJhmxHaZNgyLVA:matrix.org

binrw

18 Members
Official Matrix channel for the binread & binrw Rust libraries. Bridged to Discord. https://github.com/jam1garner/binread/3 Servers

Load older messages


SenderMessageTime
23 Apr 2021
@Skirmisher:cybre.spaceSkirmisher not sure if I'm supposed to be able to do this, but the closure being Fn seems...wrong... 21:37:16
@Skirmisher:cybre.spaceSkirmisher

also octylFractal your change fixed my original problem, but now I've restructured things and ended up doing this, which breaks xD

error[E0382]: use of moved value: `path`
  --> src/hapi.rs:58:17
   |
58 | #[derive(Debug, BinRead, Clone)]
   |                 ^^^^^^^
   |                 |
   |                 value moved into closure here
   |                 value used here after move
   |                 move occurs because `path` has type `PathBuf`, which does not implement the `Copy` trait
...
62 |     File(#[br(args(path))] HapiFile),
   |                    ---- variable moved due to use in closure
63 |     #[br(pre_assert(is_dir))]
64 |     Directory(#[br(args(path))] HapiDirectory),
   |                         ---- use occurs due to use in closure
   |
21:38:43
@Skirmisher:cybre.spaceSkirmisher I changed things around so the path/parent I'm passing around is just a PathBuf, by value 21:39:32
@Skirmisher:cybre.spaceSkirmisherbecause I'm insufferable apparently21:41:56
@_discord_101805079555764224:t2bot.iooctylFractal you might need to explicitly call clone 21:42:39
@_discord_101805079555764224:t2bot.iooctylFractal args(path.clone()) 21:42:50
@_discord_101805079555764224:t2bot.iooctylFractal alternatively perhaps the generated closures should be marked move? I'm not super good with rust closures but that seems like a possible fix 21:43:25
@Skirmisher:cybre.spaceSkirmisherright but I want to move it 😅21:43:30
@Skirmisher:cybre.spaceSkirmisherwith the enum, the problem is that both closures are capturing (moving) the value, when only one of them will be executed at runtime21:44:54
@snover:matrix.orgsnover Skirmisher: are you running with the patch from octylFractal ? 21:45:49
@_discord_101805079555764224:t2bot.iooctylFractal this is actually an incorrect analysis, both will be run, they are not on separate branches, instead binread uses pre_assert inside the closure to "cancel" going down that path and continue to the next closure 21:49:19
@Skirmisher:cybre.spaceSkirmisher snover: yes 21:49:47
@_discord_101805079555764224:t2bot.iooctylFractal so I think you will have to clone in the first case 21:50:06
@Skirmisher:cybre.spaceSkirmisher octylFractal: ah, I see 21:50:14
@_discord_101805079555764224:t2bot.iooctylFractal basically the borrow checker can't tell that you'll only use path once, because it's behind some really tricky and nested control flow 21:51:06
@_discord_101805079555764224:t2bot.iooctylFractal there might be a better way to generate the code to avoid this (maybe the closure could take in the arguments, and return them on error?), but right now you'll have to clone 21:51:48
@Skirmisher:cybre.spaceSkirmisheryeah, sounds right21:52:48
@_discord_101805079555764224:t2bot.iooctylFractal also I am not sure "borrow checker" is the right term there 🤔 21:53:26
@Skirmisher:cybre.spaceSkirmisher I may just go back to using Rc 21:53:51
@_discord_101805079555764224:t2bot.iooctylFractal yea, it'll still need an Rc::clone but at least it won't duplicate the whole path 21:54:34
@Skirmisher:cybre.spaceSkirmisherexercising the limits of these things is fun though :D21:55:48
@Skirmisher:cybre.spaceSkirmisherespecially for a library as complex as binrw21:56:15
@Skirmisher:cybre.spaceSkirmisher what about the first issue though, with map? it seems like it's unwilling to move or mutably borrow because the map closure is Fn instead of FnOnce for some reason... 21:57:42
@_discord_101805079555764224:t2bot.iooctylFractal probably because like I said, binrw generates || { } closures, not move || { } closures 21:58:34
@Skirmisher:cybre.spaceSkirmisher oh like, the closure I made is inside another closure which is Fn? 21:59:46
@Skirmisher:cybre.spaceSkirmisherthat makes the compiler error kind of misleading lol22:00:30
@Skirmisher:cybre.spaceSkirmisherit's funny business22:00:45
@_discord_102192337135886336:t2bot.ioKitlith#3594 i wonder if it would be reasonable to change that. 22:01:32
27 Apr 2021
@_discord_596527875545497600:t2bot.iolaurenceN#4134 changed their display name from laurenceN to laurenceN#4134.18:33:00
8 May 2021
@artemis21:matrix.orgArtemis joined the room.14:33:10

There are no newer messages yet.


Back to Room List