Document the use of .saturating_sub(1)
This commit is contained in:
parent
55c3701d2e
commit
d735d23ffa
2 changed files with 2 additions and 1 deletions
|
@ -39,7 +39,7 @@ pub enum MidiConfig {
|
|||
/// [`Plugin::MIDI_INPUT`][crate::prelude::Plugin::MIDI_INPUT]. Also check out the
|
||||
/// [`util`][crate::util] module for convenient conversion functions.
|
||||
///
|
||||
/// All of the timings are sample offsets within the current buffer. Out of bounds timings are
|
||||
/// All of the timings are sample offsets within the current buffer. Out of bound timings are
|
||||
/// clamped to the current buffer's length. All sample, channel and note numbers are zero-indexed.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
|
|
|
@ -65,6 +65,7 @@ pub fn strlcpy(dest: &mut [c_char], src: &str) {
|
|||
/// out of bounds.
|
||||
#[inline]
|
||||
pub fn clamp_input_event_timing(timing: u32, total_buffer_len: u32) -> u32 {
|
||||
// If `total_buffer_len == 0`, then 0 is a valid timing
|
||||
let last_valid_index = total_buffer_len.saturating_sub(1);
|
||||
|
||||
nih_debug_assert!(
|
||||
|
|
Loading…
Add table
Reference in a new issue