allaboutevemirolive / trees-rs

MIT License
0 stars 0 forks source link

Refactor: Change Registry Function Pointer Types to `Option<fn()>` #21

Open allaboutevemirolive opened 3 months ago

allaboutevemirolive commented 3 months ago

For context: https://doc.rust-lang.org/beta/std/primitive.fn.html

https://github.com/allaboutevemirolive/trees-rs/blob/a5a90585bfd48f26552ddd1e81f1cc6876c9bb05/src/config/registry.rs#L30-L56

allaboutevemirolive commented 2 months ago

I'm not convinced about this implementation. All fields will be called regardless of whether they're used, so wrapping the type in Option seems unnecessary.

The key difference is that using Option requires us to check or unwrap it for every folder iteration. Without Option, we can avoid these extra steps, either calling a function that performs an action or a no-op function.