From e2019120fd3a009097dd9a9ab6e28768d38c6a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Thu, 9 Mar 2023 22:25:41 +0100 Subject: [PATCH] Remove constraints package (#98) --- CHANGELOG.md | 9 ++++++++- constraints/constraints.go | 14 -------------- number.go | 12 ++++++------ ordered.go | 8 +++----- 4 files changed, 17 insertions(+), 26 deletions(-) delete mode 100644 constraints/constraints.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f5a28d..d5048b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,14 @@ All notable changes to this library are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/fluentassert/verify/compare/v1.0.0-rc.2...HEAD) +## [Unreleased](https://github.com/fluentassert/verify/compare/v1.0.0-rc.3...HEAD) + + +## [1.0.0-rc.3](https://github.com/fluentassert/verify/releases/tag/v1.0.0-rc.3) - 2023-03-09 + +### Removed + +- Remove `constraints` package. ## [1.0.0-rc.2](https://github.com/fluentassert/verify/releases/tag/v1.0.0-rc.2) - 2023-02-24 diff --git a/constraints/constraints.go b/constraints/constraints.go deleted file mode 100644 index 6fd8bf3..0000000 --- a/constraints/constraints.go +++ /dev/null @@ -1,14 +0,0 @@ -// Package constraints defines constraints to be used with type parameters. -package constraints - -// Number is a constraint that permits any numeric type -// that supports the operators < <= >= > + - * /. -type Number interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 -} - -// Ordered is a constraint that permits any ordered type: -// any type that supports the operators < <= >= >. -type Ordered interface { - Number | ~string -} diff --git a/number.go b/number.go index b98a20a..d8c347e 100644 --- a/number.go +++ b/number.go @@ -3,17 +3,17 @@ package verify import ( "fmt" "math" - - "github.com/fluentassert/verify/constraints" ) -// FluentNumber encapsulates assertions for numbers. -type FluentNumber[T constraints.Number] struct { +// FluentNumber encapsulates assertions for numbers +// that supports the operators < <= >= > + - * /. +type FluentNumber[T ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64] struct { FluentOrdered[T] } -// Number is used for testing numbers. -func Number[T constraints.Number](got T) FluentNumber[T] { +// Number is used for testing numbers +// that supports the operators < <= >= > + - * /. +func Number[T ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64](got T) FluentNumber[T] { return FluentNumber[T]{FluentOrdered[T]{FluentObj[T]{FluentAny[T]{got}}}} } diff --git a/ordered.go b/ordered.go index 21ebbff..38bc602 100644 --- a/ordered.go +++ b/ordered.go @@ -2,19 +2,17 @@ package verify import ( "fmt" - - "github.com/fluentassert/verify/constraints" ) // FluentOrdered encapsulates assertions for ordered object -// // that supports the operators < <= >= >. -type FluentOrdered[T constraints.Ordered] struct { +// that supports the operators < <= >= >. +type FluentOrdered[T ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string] struct { FluentObj[T] } // Ordered is used for testing a ordered object // that supports the operators < <= >= >. -func Ordered[T constraints.Ordered](got T) FluentOrdered[T] { +func Ordered[T ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string](got T) FluentOrdered[T] { return FluentOrdered[T]{FluentObj[T]{FluentAny[T]{got}}} }