Skip to content

Commit

Permalink
impl FromStr for HotspotLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
madninja committed May 24, 2024
1 parent 0c15576 commit fe5cb42
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helium-lib/src/hotspot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,13 @@ impl TryFrom<u64> for HotspotLocation {
}
}

impl FromStr for HotspotLocation {
type Err = h3o::error::InvalidCellIndex;
fn from_str(s: &str) -> StdResult<Self, Self::Err> {
s.parse::<h3o::CellIndex>().map(Into::into)
}
}

impl HotspotLocation {
pub fn from_maybe<T: TryInto<HotspotLocation>>(value: Option<T>) -> Option<Self> {
value.and_then(|v| TryInto::try_into(v).ok())
Expand Down

0 comments on commit fe5cb42

Please sign in to comment.