summaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-04-21 17:42:43 +0200
committertroido <troido@protonmail.com>2020-04-21 17:42:43 +0200
commit99e3ad27e075ccf327d0f399bfa73d75be66d13d (patch)
treef99ffc1ba861868cd5f974bb38dafdeffdf19570 /src/util.rs
parent6f85a365cb790b426b4c55f93f25420503e5af43 (diff)
use own strip_prefix function for interaction arguments
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs
index c9557b2..6a22031 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -6,6 +6,14 @@ pub fn clamp<T: Ord>(val: T, lower: T, upper: T) -> T{
}
+pub fn strip_prefix<'a>(txt: &'a str, prefix: &'a str) -> Option<&'a str> {
+ if txt.starts_with(prefix) {
+ Some(txt.split_at(prefix.len()).1)
+ } else {
+ None
+ }
+}
+
#[macro_export]
macro_rules! hashmap {
( $($key:expr => $value:expr ),* ) => {{