rcl/fuzz
Ruud van Asseldonk 0fca8c5056 Add List.{to_set_dedup,to_set_unique} methods
Naming these was a long bikeshed. Some considerations:

 * Symmetry with Set.to_list and String.to_uppercase, keep the to_.

 * Naming after an action is clearer than naming after a property,
   because for a property it's not clear whether that is a precondition
   rather than a postcondition. xs.dedup() makes it clear it removes
   duplicates, xs.unique(), does it assert it's unique? Does it test it?

 * In light of the above observation, List.sort is a good name, better
   than List.sorted.

 * The obvious one people will try is probably to_set. If it silently
   drops duplicates, that's an unsafe default. So let's make this the
   one that validates, and we can have to_set_dedup that drops
   duplicates.

 * Erroring on duplicates is always safe. We can even point the users to
   the version that drops duplicates.

 * If you read code and see xs.to_set() without any contrasting
   .to_set_dedup(), it's not so obvious that .to_set() does any
   validation, and if that is your intent, then you have to clarify
   that in a comment.

 * xs.to_set_assert_unique in that sense is clearer, but it's too
   verbose in practice. xs.to_set_nodup is a bit obscure, especially if
   you don't see the contrasting .to_set_dedup().

 * A method List.dedup that returns a list, and having to_set being the
   one that errors, also works, then you can do .dedup().to_set(), which
   is very explicit. It still does not clarify at the call site that
   to_set is validating though. It is also inefficient, but that's
   probably not a problem for RCL, and you can always use a
   comprehension if it matters.

So conclusion for now, to_set is the right prefix for symmetry and
discoverability. There is not going to be a "default" to set, you have
to explicitly choose whether you want to discard duplicates or not. The
to_set_dedup is clear for that. When reading code, to_set_unique is
maybe less obvious, but it gives more hint than to_set, and if you think
for a moment, set values are already unique, so why the _unique, and
then you find the contrast with _dedup. So far this seems like one of
the better directions.
2025-12-14 19:31:41 +01:00
..
fuzz_targets Accept and silence some Clippy advice 2025-11-23 20:45:14 +01:00
src Add List.{to_set_dedup,to_set_unique} methods 2025-12-14 19:31:41 +01:00
tools Smith: Add subcommand to evaluate corpus 2024-04-27 14:11:03 +02:00
.gitignore Add initial fuzzer 2023-08-14 21:46:30 +02:00
Cargo.rcl Dogfood dict unpack syntax in Cargo.rcl files 2025-11-22 21:33:24 +01:00
Cargo.toml Bump version to 0.11.0 2025-11-23 19:26:00 +01:00
dictionary.txt Add List.{to_set_dedup,to_set_unique} methods 2025-12-14 19:31:41 +01:00
dictionary_base.txt Include unpack in fuzz dictionary 2025-11-22 22:02:29 +01:00
dictionary_cli.txt Add --about that prints license info 2025-11-22 21:33:02 +01:00