fix(scr/error.rs): Don't require a displayable value
This commit is contained in:
parent
80392410f5
commit
9d2ae6d928
|
@ -20,21 +20,21 @@
|
||||||
* If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::{fmt::Display, num::ParseIntError};
|
use std::num::ParseIntError;
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::key_repr::{key, keys, Keys};
|
use crate::key_repr::{key, keys, Keys};
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum TrieInsertError<V: Display> {
|
pub enum TrieInsertError<V> {
|
||||||
#[error("The key ('{0}') contains nodes, which already have a value set!")]
|
#[error("The key ('{0:#?}') contains nodes, which already have a value set!")]
|
||||||
KeyPathBlocked(Keys),
|
KeyPathBlocked(Keys),
|
||||||
|
|
||||||
#[error("The key ('{key}') already has a value associatet with it, which is: '{value}'")]
|
#[error("The key ('{key:#?}') already has a value associatet with it, which is: '{value}'")]
|
||||||
KeyAlreadySet { key: Keys, value: V },
|
KeyAlreadySet { key: Keys, value: V },
|
||||||
|
|
||||||
#[error("The node accessed by this key ('{0}') already has children! You can not set a value for it")]
|
#[error("The node accessed by this key ('{0:#?}') already has children! You can not set a value for it")]
|
||||||
NodeHasChildren(Keys),
|
NodeHasChildren(Keys),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,20 +29,20 @@ use crate::error;
|
||||||
use super::key_repr::{Key, Keys};
|
use super::key_repr::{Key, Keys};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct Node<V: std::fmt::Display + ToOwned<Owned = V>> {
|
pub struct Node<V> {
|
||||||
children: HashMap<Key, Box<Node<V>>>,
|
children: HashMap<Key, Box<Node<V>>>,
|
||||||
value: Option<V>,
|
value: Option<V>,
|
||||||
is_terminal: bool,
|
is_terminal: bool,
|
||||||
is_child: bool,
|
is_child: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: std::fmt::Display + ToOwned<Owned = V>> Default for Node<V> {
|
impl<V: ToOwned<Owned = V>> Default for Node<V> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: std::fmt::Display + ToOwned<Owned = V>> Node<V> {
|
impl<V: ToOwned<Owned = V>> Node<V> {
|
||||||
pub fn new() -> Node<V> {
|
pub fn new() -> Node<V> {
|
||||||
Node {
|
Node {
|
||||||
children: HashMap::new(),
|
children: HashMap::new(),
|
||||||
|
|
Reference in New Issue