Skip to content

Commit 684d180

Browse files
committed
refactor(unit): update function signatures for consistency and clarity
1 parent fff3146 commit 684d180

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

unit/README.mbt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test "unit construction" {
2222
2323
// Via default constructor
2424
let u2 = @unit.default()
25-
25+
fn println(_ : String) {}
2626
// All unit values are identical
2727
inspect(u1 == u2, content="true")
2828
@@ -45,7 +45,7 @@ Functions that return `Unit` are typically called for their side effects:
4545
```moonbit
4646
test "side effect patterns" {
4747
let numbers = [1, 2, 3, 4, 5]
48-
48+
fn println(_ : Int) {}
4949
// Processing for side effects (printing, logging, etc.)
5050
let processing_result = numbers.fold(init=(), fn(_acc, n) {
5151
// Simulated side effect

unit/unit.mbt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@
1313
// limitations under the License.
1414

1515
///|
16-
pub fn to_string(self : Unit) -> String {
17-
let _ = self
16+
pub fn Unit::to_string(_ : Self) -> String {
1817
"()"
1918
}
2019

2120
///|
22-
pub impl Hash for Unit with hash(self) {
23-
let _ = self
21+
pub impl Hash for Unit with hash(_) -> Int {
2422
0
2523
}
2624

2725
///|
28-
pub impl Hash for Unit with hash_combine(self, hasher) -> Unit {
29-
let _ = self
26+
pub impl Hash for Unit with hash_combine(_, hasher) -> Unit {
3027
hasher.combine_unit()
3128
}
3229

@@ -42,6 +39,6 @@ pub fn default() -> Unit {
4239
}
4340

4441
///|
45-
pub impl Compare for Unit with compare(_self, _other) {
42+
pub impl Compare for Unit with compare(_, _) {
4643
0
4744
}

0 commit comments

Comments
 (0)