Skip to content

Commit

Permalink
type-safer offset ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
kstep committed Feb 28, 2021
1 parent 5d8f9d2 commit 9e4adbd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/model/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ pub enum Offset<T> {
Uri(IdBuf<T>),
}

impl<T> Offset<T> {
impl Offset<idtypes::Track> {
pub fn for_position(position: u64) -> Offset<idtypes::Track> {
Offset::Position(Duration::from_millis(position))
}
}

pub fn for_uri(uri: &Id<T>) -> Offset<T>
where
T: PlayableIdType,
{
impl<T: PlayableTypeId> Offset<T> {
pub fn for_uri(uri: &Id<T>) -> Offset<T> {
Offset::Uri(uri.to_owned())
}
}

0 comments on commit 9e4adbd

Please sign in to comment.