If rate values > 100 are passed in, cap them at 100.

This commit is contained in:
Nolan Darilek 2019-10-09 16:12:47 -05:00
parent 1bb0f56f40
commit c9c2f182cd

View File

@ -31,7 +31,10 @@ impl NativeClass for TTS {
let rate = this.0.get_rate().unwrap(); let rate = this.0.get_rate().unwrap();
rate / u8::MAX * 100 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; let v = v / 100 * u8::MAX;
this.0.set_rate(v as u8).unwrap(); this.0.set_rate(v as u8).unwrap();
}, },