|
1 | 1 | //go:build go1.18 |
2 | 2 |
|
3 | | -package sync |
| 3 | +package syncext |
4 | 4 |
|
5 | 5 | import ( |
6 | 6 | "sync" |
7 | 7 |
|
8 | | - "github.com/go-playground/pkg/v5/values/result" |
| 8 | + resultext "github.com/go-playground/pkg/v5/values/result" |
9 | 9 | ) |
10 | 10 |
|
11 | 11 | // NewMutex creates a new Mutex for use. |
@@ -45,11 +45,11 @@ func (m *Mutex[T]) Unlock() { |
45 | 45 |
|
46 | 46 | // TryLock tries to lock Mutex and reports whether it succeeded. |
47 | 47 | // If it does the value is returned for use in the Ok result otherwise Err with empty value. |
48 | | -func (m *Mutex[T]) TryLock() result.Result[T, struct{}] { |
| 48 | +func (m *Mutex[T]) TryLock() resultext.Result[T, struct{}] { |
49 | 49 | if m.m.TryLock() { |
50 | | - return result.Ok[T, struct{}](m.value) |
| 50 | + return resultext.Ok[T, struct{}](m.value) |
51 | 51 | } else { |
52 | | - return result.Err[T, struct{}](struct{}{}) |
| 52 | + return resultext.Err[T, struct{}](struct{}{}) |
53 | 53 | } |
54 | 54 | } |
55 | 55 |
|
@@ -89,11 +89,11 @@ func (m *RWMutex[T]) Unlock() { |
89 | 89 |
|
90 | 90 | // TryLock tries to lock RWMutex and returns the value in the Ok result if successful. |
91 | 91 | // If it does the value is returned for use in the Ok result otherwise Err with empty value. |
92 | | -func (m *RWMutex[T]) TryLock() result.Result[T, struct{}] { |
| 92 | +func (m *RWMutex[T]) TryLock() resultext.Result[T, struct{}] { |
93 | 93 | if m.rw.TryLock() { |
94 | | - return result.Ok[T, struct{}](m.value) |
| 94 | + return resultext.Ok[T, struct{}](m.value) |
95 | 95 | } else { |
96 | | - return result.Err[T, struct{}](struct{}{}) |
| 96 | + return resultext.Err[T, struct{}](struct{}{}) |
97 | 97 | } |
98 | 98 | } |
99 | 99 |
|
@@ -121,10 +121,10 @@ func (m *RWMutex[T]) RUnlock() { |
121 | 121 |
|
122 | 122 | // TryRLock tries to lock RWMutex for reading and returns the value in the Ok result if successful. |
123 | 123 | // If it does the value is returned for use in the Ok result otherwise Err with empty value. |
124 | | -func (m *RWMutex[T]) TryRLock() result.Result[T, struct{}] { |
| 124 | +func (m *RWMutex[T]) TryRLock() resultext.Result[T, struct{}] { |
125 | 125 | if m.rw.TryRLock() { |
126 | | - return result.Ok[T, struct{}](m.value) |
| 126 | + return resultext.Ok[T, struct{}](m.value) |
127 | 127 | } else { |
128 | | - return result.Err[T, struct{}](struct{}{}) |
| 128 | + return resultext.Err[T, struct{}](struct{}{}) |
129 | 129 | } |
130 | 130 | } |
0 commit comments