Fix All sources for not stopping when input sources are stopped. #29

Closed
opened 2024-09-08 02:37:21 +00:00 by Lubba-64 · 1 comment
Lubba-64 commented 2024-09-08 02:37:21 +00:00 (Migrated from github.com)

Make sure any input source returning None causes the current source to also return None.
Example:

// before:
impl<I: Source<Item = f32>> Iterator for RawMod<I> {
    type Item = f32;

    #[inline]
    fn next(&mut self) -> Option<f32> {
        Some(self.source.next().unwrap_or(0.0) % self.mod_by)
    }
}
// after:
impl<I: Source<Item = f32>> Iterator for RawMod<I> {
    type Item = f32;

    #[inline]
    fn next(&mut self) -> Option<f32> {
        match self.source.next() {
            Some(x) => Some(x % self.mod_by),
            None => None,
        }
    }
}
Make sure any input source returning `None` causes the current source to also return `None`. Example: ```rust // before: impl<I: Source<Item = f32>> Iterator for RawMod<I> { type Item = f32; #[inline] fn next(&mut self) -> Option<f32> { Some(self.source.next().unwrap_or(0.0) % self.mod_by) } } // after: impl<I: Source<Item = f32>> Iterator for RawMod<I> { type Item = f32; #[inline] fn next(&mut self) -> Option<f32> { match self.source.next() { Some(x) => Some(x % self.mod_by), None => None, } } } ```
Lubba-64 commented 2024-09-08 02:43:04 +00:00 (Migrated from github.com)

When you comment / start on this issue, make sure to make a checklist of all the nodes that always return Some and update them to fix this issue 👍

When you comment / start on this issue, make sure to make a checklist of all the nodes that always return Some and update them to fix this issue :+1:
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lubba64/node_sound#29
No description provided.