From c9c2f182cd8fd9b34fb5ab29efefd08801bc5eef Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 9 Oct 2019 16:12:47 -0500 Subject: [PATCH] If rate values > 100 are passed in, cap them at 100. --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2d06c2a..bf70f7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,10 @@ impl NativeClass for TTS { let rate = this.0.get_rate().unwrap(); rate / u8::MAX * 100 }, - setter: |this: &mut TTS, v: u8| { + setter: |this: &mut TTS, mut v: u8| { + if v > 100 { + v = 100; + } let v = v / 100 * u8::MAX; this.0.set_rate(v as u8).unwrap(); },