Skip to content

Commit

Permalink
use 'thiserror' to define 'Error'
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Oct 19, 2024
1 parent 5e980e7 commit 1bc2442
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rand = "0.8.5"

[dependencies]
glam = { version = "0.29.0", optional = true }
thiserror = "1.0.64"

[features]
glam = ["dep:glam"]
Expand Down
13 changes: 2 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ pub extern crate glam;

use core::{
f32::consts::PI,
fmt,
ops::{Add, Range},
result,
};
#[cfg(feature = "glam")]
use glam::Vec2;
use std::error::Error;

/// The three segment types in a Dubin's Path
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
Expand Down Expand Up @@ -160,17 +158,10 @@ impl PathType {
}

/// The error returned when a path is not found
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, thiserror::Error)]
#[error("No path exists with given parameters")]
pub struct NoPathError;

impl fmt::Display for NoPathError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "No path exists with given parameters")
}
}

impl Error for NoPathError {}

/// A type that allows the function to return either
///
/// Ok(T) or Err([`NoPathError`])
Expand Down

0 comments on commit 1bc2442

Please sign in to comment.