about summary refs log tree commit diff stats
path: root/sys/nixpkgs/pkgs/lf-make-map/src/mapping/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'sys/nixpkgs/pkgs/lf-make-map/src/mapping/mod.rs')
-rw-r--r--sys/nixpkgs/pkgs/lf-make-map/src/mapping/mod.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/nixpkgs/pkgs/lf-make-map/src/mapping/mod.rs b/sys/nixpkgs/pkgs/lf-make-map/src/mapping/mod.rs
index 129e9673..114fdca0 100644
--- a/sys/nixpkgs/pkgs/lf-make-map/src/mapping/mod.rs
+++ b/sys/nixpkgs/pkgs/lf-make-map/src/mapping/mod.rs
@@ -5,7 +5,6 @@ use std::{
 
 use log::debug;
 
-pub mod error;
 pub mod map_tree;
 
 #[derive(Clone, Debug, Eq)]
@@ -77,7 +76,6 @@ impl MapKey {
 
             generated_chars
         };
-        assert_eq!(added_chars.len(), new_resolution,);
 
         let part_path = self.part_path.clone();
         let output: Vec<Self> = added_chars
@@ -101,6 +99,15 @@ impl MapKey {
         fn make(pat: char, part: &str, number_of_chars: usize) -> String {
             let mut acc = String::new();
 
+            if !part.split(pat).all(|part| part.len() > 0) {
+                panic!(
+                    "\
+Can't turn this path '{}' to a mapping.
+This should not happen, please report the bug!",
+                    part
+                )
+            }
+
             let mut last_working = None;
             for i in 0..number_of_chars {
                 for str in part.split(pat) {
@@ -123,9 +130,9 @@ impl MapKey {
             acc
         }
 
-        let value = if part.contains('_') {
+        let value = if part.contains('_') && !part.starts_with('_') && !part.ends_with('_') {
             make('_', part, number_of_chars)
-        } else if part.contains('-') {
+        } else if part.contains('-') && !part.starts_with('-') && !part.ends_with('-') {
             make('-', part, number_of_chars)
         } else {
             part.chars().take(number_of_chars).collect::<String>()
@@ -134,7 +141,7 @@ impl MapKey {
         assert_eq!(
             value.len(),
             number_of_chars,
-            "'{}' is not {}",
+            "'{}' does not have expected length of: {}",
             value,
             number_of_chars
         );