Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Compare method which forwards calls to Cmp #346

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

acln0
Copy link
Contributor

@acln0 acln0 commented Jan 23, 2024

Given the interface definition

type Ordered[T any] interface {
	Compare(T) int
}

And the type constraint T Ordered[T], make decimal.Decimal satisfy this constraint, so that generic code written against T Ordered[T] can work with decimal values as smoothly as it works with time.Time values today.

Fixes: #345

Given the interface definition

	type Ordered[T any] interface {
		Compare(T) int
	}

And the type constraint T Ordered[T], make decimal.Decimal satisfy this
constraint, so that generic code written against T Ordered[T] can work
with decimal values as smoothly as it works with time.Time values today.

Fixes: shopspring#345
Copy link
Member

@mwoss mwoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT! Thanks for your contribution!

@mwoss mwoss merged commit 57a340d into shopspring:master Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Compare method to enable smoother generic programming against decimal.Decimal
2 participants