-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
MustParseDecimal
function (#766)
- Loading branch information
1 parent
b5dcc5a
commit 61aa7cb
Showing
3 changed files
with
24 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
package numbers | ||
|
||
import "github.com/cockroachdb/apd/v3" | ||
|
||
// BetweenEq - Looks something like this. start <= number <= end | ||
func BetweenEq[T int | int32 | int64](start, end, number T) bool { | ||
return number >= start && number <= end | ||
} | ||
|
||
// MustParseDecimal parses a string to a [*apd.Decimal] or panics -- used for tests. | ||
func MustParseDecimal(value string) *apd.Decimal { | ||
decimal, _, err := apd.NewFromString(value) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return decimal | ||
} |