conradludgate / wordle

Wordle TUI in Rust
122 stars 21 forks source link

add instructions to enable daily game #23

Closed rneswold closed 2 years ago

rneswold commented 2 years ago

To play the current day's puzzle, the application needs to determine the player's timezone offset. The time crate considers this computation "unsound". But the way this application uses it, it's safe.

This commit adds instructions to make it build a version so you can play daily -- without having to keep track of the day number.

conradludgate commented 2 years ago

Do you have a source for the soundness issue?

rneswold commented 2 years ago

It's at the end of the "Features" section (https://docs.rs/time/0.3.7/time/)

One pseudo-feature flag that is only available to end users is the unsound_local_offset cfg. As the name indicates, using the feature is unsound, and may cause unexpected segmentation faults. Unlike other flags, this is deliberately only available to end users; this is to ensure that a user doesn’t have unsound behavior without knowing it. To enable this behavior, you must use RUSTFLAGS="--cfg unsound_local_offset" cargo build or similar.

Adding that config option allows wordle to determine the current day's puzzle.

(update) What it boils down to is, if multiple threads are both reading and changing the time zone, it could segfault. Your project doesn't do that, so it's safe to use.

rneswold commented 2 years ago

Maybe the config option can be placed in Cargo.toml, since we know it's safe to use in this application.