Skip to content

Commit

Permalink
bed/feature/record_buf/other_fields/value: Add conversions from raw v…
Browse files Browse the repository at this point in the history
…alues
  • Loading branch information
zaeleus committed Aug 1, 2024
1 parent 1a8e243 commit 7e3b517
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions noodles-bed/src/feature/record_buf/other_fields/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,36 @@ pub enum Value {
String(BString),
}

impl From<i64> for Value {
fn from(n: i64) -> Self {
Self::Int64(n)
}
}

impl From<u64> for Value {
fn from(n: u64) -> Self {
Self::UInt64(n)
}
}

impl From<f64> for Value {
fn from(n: f64) -> Self {
Self::Float64(n)
}
}

impl From<&str> for Value {
fn from(s: &str) -> Self {
Self::from(String::from(s))
}
}

impl From<String> for Value {
fn from(s: String) -> Self {
Self::String(s.into())
}
}

impl<'a> From<&'a Value> for crate::feature::record::other_fields::Value<'a> {
fn from(value_buf: &'a Value) -> Self {
match value_buf {
Expand Down

0 comments on commit 7e3b517

Please sign in to comment.