Skip to content

Commit

Permalink
feat: Use starts_with and ends_with from Rust instead of gluon
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Sep 13, 2016
1 parent 0a6b65b commit 5144ee2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 2 additions & 12 deletions std/string.glu
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ let monoid = {
empty = ""
}

let starts_with haystack needle =
match string_prim.find haystack needle with
| Some i -> i == 0
| None -> False

let ends_with haystack needle =
match string_prim.rfind haystack needle with
| Some i -> i == string_prim.length haystack - string_prim.length needle
| None -> False

let eq : Eq String = {
(==) = string_prim.eq
}
Expand All @@ -43,7 +33,7 @@ let show : Show String = {
ord,
show,
slice = string_prim.slice,
starts_with,
ends_with,
starts_with = string_prim.starts_with,
ends_with = string_prim.ends_with,
monoid
}
2 changes: 2 additions & 0 deletions vm/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ pub fn load(vm: &Thread) -> Result<()> {
split_at => primitive!(2 str::split_at),
find => primitive!(2 str::find::<&str>),
rfind => primitive!(2 str::rfind::<&str>),
starts_with => primitive!(2 str::starts_with::<&str>),
ends_with => primitive!(2 str::ends_with::<&str>),
trim => primitive!(1 str::trim),
trim_left => primitive!(1 str::trim_left),
trim_right => primitive!(1 str::trim_right),
Expand Down

0 comments on commit 5144ee2

Please sign in to comment.