selene-core 0.5.3

selene-core is the backend for Selene, a local-first music player
Documentation
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct LyricSpan {
    pub start_us: u32,
    pub vocals: String,
    pub vocalists: Vec<u8>,
}

impl LyricSpan {
    pub fn span_end_us(&self, lines: &[LyricSpan], line_end: u32) -> u32 {
        let pos = lines
            .iter()
            .position(|l| std::ptr::eq(self, l))
            .expect("self (LyricSpan) is not contained in the slice");

        lines.get(pos + 1).map(|l| l.start_us).unwrap_or(line_end)
    }
}