Add comments to generic functions

This commit is contained in:
Jason Streifling 2024-10-20 12:30:23 +02:00
parent c0f5306715
commit b6b8970810

View File

@ -16,6 +16,7 @@ type Countable interface {
*xml.Attr | *Person | *Category | *Link | *ExtensionElement | *Entry
}
// addToSlice adds a Countable to to a *[]Countable
func addToSlice[C Countable](slice *[]C, countable C) {
if *slice == nil {
*slice = make([]C, 0)
@ -23,6 +24,8 @@ func addToSlice[C Countable](slice *[]C, countable C) {
*slice = append(*slice, countable)
}
// deleteFromSlice deletes the Countable with the index from the *[]Countable.
// It return an error.
func deleteFromSlice[C Countable](slice *[]C, id int) error {
length := len(*slice)
if id > length {