Anders429 / word_filter

A Word Filter for filtering text.
Apache License 2.0
1 stars 0 forks source link

Use new() method instead of having structs public #68

Open Anders429 opened 3 years ago

Anders429 commented 3 years ago

Rather than having all of the different internal structs have public visibility, it may be possible to use a new() method on WordFilter to construct it instead. The new() method would need to be a const fn to be used in static context.

The input parameter would just be a fixed-size array of size N, with each element being a tuple containing the values needed for a State, which are:

The references may be a problem, since they reference into the array being constructed in the new() method. This may not have to be a problem though, depending on how self-referencing works in const contexts.

Anders429 commented 3 years ago

The array-const-fn-init crate may be required to make this possible at this point. May need to experiment to see if it can be used with a const generic.

Edit: nevermind, this doesn't work with const generics :(

Anders429 commented 3 years ago

Looks like this is going to be blocked by the const_fn_fn_ptr_basics feature becoming stable, since it is needed to allow a function pointer to appear as a const fn parameter.