Skip to content

Commit

Permalink
drop dependency on golang.org/x/exp/constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
b97tsk committed Aug 12, 2024
1 parent ebc32b0 commit 1f61c28
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
6 changes: 6 additions & 0 deletions constraints.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package rx

// Integer is a constraint that permits any integer type.
type Integer interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ module github.com/b97tsk/rx

go 1.22.0

require golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8

retract [v0.0.1, v0.9.0]
2 changes: 0 additions & 2 deletions go.sum

This file was deleted.

4 changes: 1 addition & 3 deletions pair.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package rx

import "golang.org/x/exp/constraints"

// A Pair is a struct of two elements.
type Pair[K, V any] struct {
Key K
Expand Down Expand Up @@ -97,7 +95,7 @@ func RightOf[_ Pair[K, V], K, V any]() Operator[Pair[K, V], V] {
// Enumerate maps each value emitted by the source [Observable] to a [Pair]
// where the Key field stores the index of each value starting from init
// and the Value field stores each value.
func Enumerate[V any, K constraints.Integer](init K) Operator[V, Pair[K, V]] {
func Enumerate[V any, K Integer](init K) Operator[V, Pair[K, V]] {
return NewOperator(
func(source Observable[V]) Observable[Pair[K, V]] {
return func(c Context, o Observer[Pair[K, V]]) {
Expand Down
6 changes: 2 additions & 4 deletions range.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package rx

import "golang.org/x/exp/constraints"

// Range creates an [Observable] that emits a sequence of integers
// within a specified range.
func Range[T constraints.Integer](low, high T) Observable[T] {
func Range[T Integer](low, high T) Observable[T] {
return func(c Context, o Observer[T]) {
done := c.Done()

Expand All @@ -25,7 +23,7 @@ func Range[T constraints.Integer](low, high T) Observable[T] {

// Iota creates an [Observable] that emits an infinite sequence of integers
// starting from init.
func Iota[T constraints.Integer](init T) Observable[T] {
func Iota[T Integer](init T) Observable[T] {
return func(c Context, o Observer[T]) {
done := c.Done()

Expand Down

0 comments on commit 1f61c28

Please sign in to comment.