Skip to content

Commit

Permalink
docs(api): update function documentation and add new functions
Browse files Browse the repository at this point in the history
- Update documentation for existing functions in generic package
- Add new functions: ChooseLeft, ChooseRight, OnlyLeft, OnlyMiddle, OnlyRight
- Update function signatures and descriptions for maps package
- Add new functions: MergeMaps, MergeMapsFunc, Transform
- Update function documentation for settings package
- Add new functions: ApplyDefaults, ApplyDefaultsOr, ApplyDefaultsOrError, ApplyDefaultsOrZero
- Add new types: Defaulter, ErrorDefaulter
- Update function documentation for sync package
- Add new type: Map
- Update function documentation for trans package
- Update function documentation for types package
  • Loading branch information
godcong committed Dec 30, 2024
1 parent 446172e commit 17a5bae
Show file tree
Hide file tree
Showing 2 changed files with 422 additions and 59 deletions.
36 changes: 36 additions & 0 deletions choose.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 OrigAdmin. All rights reserved.
*/

// Package generic implements the functions, types, and interfaces for the module.
package generic

// ChooseRight returns the rightmost value, ignoring the left value.
// This function is useful when you need to prioritize the right value over the left.
func ChooseRight[L any, R any](_ L, r R) R {
return r
}

// ChooseLeft returns the leftmost value, ignoring the right value.
// This function is useful when you need to prioritize the left value over the right.
func ChooseLeft[L any, R any](l L, _ R) L {
return l
}

// OnlyLeft returns the leftmost value, ignoring all other values.
// This function is useful when you need to extract the leftmost value from a tuple.
func OnlyLeft[L any, R1 any, R2 any](l L, _ R1, _ R2) L {
return l
}

// OnlyRight returns the rightmost value, ignoring all other values.
// This function is useful when you need to extract the rightmost value from a tuple.
func OnlyRight[L1 any, L2 any, R any](_ L1, _ L2, r R) R {
return r
}

// OnlyMiddle returns the middle value, ignoring all other values.
// This function is useful when you need to extract the middle value from a tuple.
func OnlyMiddle[L any, M any, R any](_ L, m M, _ R) M {
return m
}
Loading

0 comments on commit 17a5bae

Please sign in to comment.