Skip to content

Commit

Permalink
HW02 remove pkg 'slices'
Browse files Browse the repository at this point in the history
  • Loading branch information
DimVlas authored and DimVlas committed Apr 13, 2024
1 parent 858143f commit 5229f44
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hw02_unpack_string/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package hw02unpackstring
import (
"errors"
"fmt"
"slices"
"strconv"
"strings"
)
Expand All @@ -20,7 +19,12 @@ var (

// True - если руна является цифрой.
func IsDigit(r rune) bool {
return slices.Contains(nums, r)
for _, num := range nums {
if num == r {
return true
}
}
return false
}

func Unpack(text string) (string, error) {
Expand All @@ -47,7 +51,7 @@ func Unpack(text string) (string, error) {
return "", ErrInvalidString
}

if !IsDigit(runes[i+1]) && runes[i+1] != bslash { // следующий символ не цифра ине слэш
if !IsDigit(runes[i+1]) && runes[i+1] != bslash { // следующий символ не цифра и не слэш
return "", ErrInvalidString
}

Expand Down

0 comments on commit 5229f44

Please sign in to comment.