Compare commits

...

3 Commits

5 changed files with 19 additions and 11 deletions

2
Cargo.lock generated
View File

@ -101,7 +101,7 @@ dependencies = [
[[package]]
name = "keymaps"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"crossterm",
"log",

View File

@ -21,11 +21,11 @@
[package]
name = "keymaps"
description = "A rust crate which provides a standardized encoding for key codes"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "LGPL-3.0-or-later"
repository = "https://git.nerdcult.net/trinitrix/keymaps"
categories = ["command-line, tui, library"]
categories = ["command-line-interface", "data-structures", "encoding"]
keywords = ["keymaps", "keychords", "vim"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -24,6 +24,14 @@ If not, see <https://www.gnu.org/licenses/>.
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
- - -
## [v0.1.1](https://codeberg.org/trinitrix/keymaps/compare/3957747ce4c7c19b2dafe5796577ec9aa99dbade..v0.1.1) - 2024-05-03
#### Bug Fixes
- **(Cargo.toml)** Add correct categories - ([8039241](https://codeberg.org/trinitrix/keymaps/commit/80392410f56188665c533555e8fa4fc074c2b1c8)) - [@soispha](https://codeberg.org/soispha)
- **(Cargo.toml)** Add required metadata - ([3957747](https://codeberg.org/trinitrix/keymaps/commit/3957747ce4c7c19b2dafe5796577ec9aa99dbade)) - [@soispha](https://codeberg.org/soispha)
- **(scr/error.rs)** Don't require a displayable value - ([9d2ae6d](https://codeberg.org/trinitrix/keymaps/commit/9d2ae6d928ecccaf15b7e4a3c98f9a68ad6b4f46)) - [@soispha](https://codeberg.org/soispha)
- - -
## [v0.1.0](https://codeberg.org/trinitrix/keymaps/compare/2f9942640a84a4aa8d34c16b839f0749893dc1d0..v0.1.0) - 2024-05-03
#### Build system
- **(Cargo.lock)** Check in to avoid not reproducible builds - ([de9562b](https://codeberg.org/trinitrix/keymaps/commit/de9562b6754003ad67acb90023859037f8efd22a)) - [@soispha](https://codeberg.org/soispha)

View File

@ -20,21 +20,21 @@
* If not, see <https://www.gnu.org/licenses/>.
*/
use std::{fmt::Display, num::ParseIntError};
use std::num::ParseIntError;
use thiserror::Error;
use crate::key_repr::{key, keys, Keys};
#[derive(Error, Debug)]
pub enum TrieInsertError<V: Display> {
#[error("The key ('{0}') contains nodes, which already have a value set!")]
pub enum TrieInsertError<V> {
#[error("The key ('{0:#?}') contains nodes, which already have a value set!")]
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 },
#[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),
}

View File

@ -29,20 +29,20 @@ use crate::error;
use super::key_repr::{Key, Keys};
#[derive(Debug, PartialEq, Eq)]
pub struct Node<V: std::fmt::Display + ToOwned<Owned = V>> {
pub struct Node<V> {
children: HashMap<Key, Box<Node<V>>>,
value: Option<V>,
is_terminal: 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 {
Self::new()
}
}
impl<V: std::fmt::Display + ToOwned<Owned = V>> Node<V> {
impl<V: ToOwned<Owned = V>> Node<V> {
pub fn new() -> Node<V> {
Node {
children: HashMap::new(),