sunjay / turtle

Create Animated Drawings in Rust
http://turtle.rs
Mozilla Public License 2.0
559 stars 54 forks source link

Fix #205: update glutin #208

Closed PaulDance closed 3 years ago

PaulDance commented 3 years ago

This fixes #205. The latest glutin version bumps winit's which introduces a number of breaking changes including renaming some enumeration variants:

Breaking: Prefixed virtual key codes Add, Multiply, Divide, Decimal, and Subtract with Numpad.

This meant that matches on previous names obviously failed, but not at compile-time however: because the function imported the enumeration's variants locally, previous names thus matched anything. That caused Add to be understood as a name binding instead of a variant: the compiler only raised warnings, but not proper errors. Note that all the tests ran just fine, even with the warnings being emitted. Of course the CI being configured to reject warnings helped us catch this, but in order to avoid such a confusion in the future, this PR not only fixes the matter at hand by adding the Numpad prefix to all changed names, but also puts the enumeration name in the match arms instead of importing them. That would help raise a more specific error sooner. This strategy has been applied to other match expressions in the module as well. Also, the unsupported keys have all been put in a _ match arm pattern instead of listing the rest of them, which was useless and error-prone as additional variants were also added in the version bump.

Winit's changelog seems to indicate that the introduced breaking changes were meant to help differentiate between the usual minus key and the numpad's one:

Breaking: On X11, - key is mapped to the Minus virtual key code, instead of Subtract.

This could mean that:

codecov[bot] commented 3 years ago

Codecov Report

Merging #208 into master will not change coverage. The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #208   +/-   ##
=======================================
  Coverage   60.81%   60.81%           
=======================================
  Files          40       40           
  Lines        2636     2636           
=======================================
  Hits         1603     1603           
  Misses       1033     1033           
Impacted Files Coverage Δ
src/event.rs 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cf1575d...27a9fd5. Read the comment docs.