• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

enetx / g / 15761286554

19 Jun 2025 03:20PM UTC coverage: 85.945% (-0.05%) from 85.998%
15761286554

push

github

enetx
ref all entry

154 of 176 new or added lines in 7 files covered. (87.5%)

2 existing lines in 1 file now uncovered.

3877 of 4511 relevant lines covered (85.95%)

106.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/map_ordered_entry.go
1
package g
2

3
import "slices"
4

5
// Get returns Some(value) if present, otherwise None.
NEW
6
func (e MapOrdEntry[K, V]) Get() Option[V] {
×
NEW
7
        return e.mo.Get(e.key)
×
NEW
8
}
×
9

10
// OrSet inserts value if the key is vacant.
11
// Returns Some(existing_value) if key was present, None otherwise.
12
func (e MapOrdEntry[K, V]) OrSet(value V) Option[V] {
4✔
13
        if i := e.mo.index(e.key); i != -1 {
5✔
14
                return Some((*e.mo)[i].Value)
1✔
15
        }
1✔
16

17
        e.mo.Set(e.key, value)
3✔
18

3✔
19
        return None[V]()
3✔
20
}
21

22
// OrSetBy inserts the value produced by fn if the key is vacant.
23
// Returns Some(existing_value) if key was present, None otherwise.
24
func (e MapOrdEntry[K, V]) OrSetBy(fn func() V) Option[V] {
2✔
25
        if i := e.mo.index(e.key); i != -1 {
3✔
26
                return Some((*e.mo)[i].Value)
1✔
27
        }
1✔
28

29
        e.mo.Set(e.key, fn())
1✔
30

1✔
31
        return None[V]()
1✔
32
}
33

34
// OrDefault inserts V's zero value if the key is vacant.
35
// Returns Some(existing_value) if key was present, None otherwise.
36
func (e MapOrdEntry[K, V]) OrDefault() Option[V] {
1✔
37
        var zero V
1✔
38
        return e.OrSet(zero)
1✔
39
}
1✔
40

41
// Transform applies fn to the value if it exists.
42
// Returns Some(updated_value) if key was present, None otherwise.
43
func (e MapOrdEntry[K, V]) Transform(fn func(V) V) Option[V] {
2✔
44
        if i := e.mo.index(e.key); i != -1 {
3✔
45
                value := fn((*e.mo)[i].Value)
1✔
46
                (*e.mo)[i].Value = value
1✔
47

1✔
48
                return Some(value)
1✔
49
        }
1✔
50

51
        return None[V]()
1✔
52
}
53

54
// Set sets the value for the specified key in the ordered map.
55
// Returns Some(previous_value) if the key existed, or None if it was newly inserted.
56
func (e MapOrdEntry[K, V]) Set(value V) Option[V] {
1✔
57
        return e.mo.Set(e.key, value)
1✔
58
}
1✔
59

60
// Delete removes the key from the Map.
61
// Returns Some(removed_value) if present, None otherwise.
62
func (e MapOrdEntry[K, V]) Delete() Option[V] {
1✔
63
        if i := e.mo.index(e.key); i != -1 {
2✔
64
                value := (*e.mo)[i].Value
1✔
65
                *e.mo = slices.Delete(*e.mo, i, i+1)
1✔
66

1✔
67
                return Some(value)
1✔
68
        }
1✔
69

NEW
70
        return None[V]()
×
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc