Closed novafacing closed 11 months ago
I'm... not 100% sure how I feel about this. I'm still on the fence about allowing default
expressions access to the previous fields - this is an undocumented feature, which may prevent the ability to split things out to traits in the future.
I'll allow it, but keep in mind that it might be broken in the future. Probably in favor of something like #75 (which in this case would mean the shmem_provider
would be passed as a context, and then maybe moved/cloned into its own field)
One change I must insist on though - one of Rust's basic tenants is that immutable should be the default, and I really don't think this rule should be violated here. The mutability should be triggered by something in the attribute:
/// The sharedmem provider to get new sharaed maps if we're full
#[builder(mutable_during_default_resolution)]
shmem_provider: SP,
Yes, it's long. Ugly features get ugly names.
Also, this means it needs to wait until #116 gets in. Or at least until I cherry-pick some commits from it.
Sure thing and sound reasoning, I'll make that change! I'll stay in tune with updates as they happen and in progress PRs. Happy to work on making mutability more idiomatic in the future -- for now, this will be a very helpful stopgap!
I will also document the feature unless you'd prefer it remains undocumented 😉
The new attribute should go in FieldBuilderAttr
.
Ok, added a doc entry and added that field attribute! I didn't see any negative tests, but I deleted mutable_during_default_resolution
manually to make sure I get an error :)
Resolved those three notes, thanks!
Very small change to allow a use case for LibAFL where a
default =
expression needs to mutate another field. Here's a snippet for example: