Skip to content

Commit

Permalink
Std: simplify variants
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Feb 11, 2024
1 parent 7d15999 commit 8950314
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/std/iter/intersperseIter.no
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl <T> Iter<T> for IntersperseIter<T> {
fn next(self): Option<T> {
if self.needsSeparator && self.iter.peek().isSome() {
self.needsSeparator = false
Option::Some(self.separator)
Some(self.separator)
} else {
self.needsSeparator = true
self.iter.next()
Expand All @@ -22,7 +22,7 @@ pub trait IntersperseAdapter<Self: Iter<T>, T> {

impl <T> IntersperseAdapter<T> for Iter<T> {
fn intersperse(self, separator: T): IntersperseIter<T> {
IntersperseIter::IntersperseIter(iter: self, separator: separator, needsSeparator: false)
IntersperseIter(iter: self, separator, needsSeparator: false)
}
}

2 changes: 1 addition & 1 deletion src/std/iter/mapIter.no
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait MapAdapter<Self: Iter<T>, T> {

impl <T> MapAdapter<T> for Iter<T> {
fn map<U>(self, f: |T|: U): MapIter<T, U> {
MapIter::MapIter(iter: self, f: f)
MapIter(iter: self, f: f)
}
}

12 changes: 6 additions & 6 deletions src/std/iter/peekable.no
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ pub type PeekableIter<T>(
impl <T> Iter<T> for PeekableIter<T> {
fn next(self): Option<T> {
match self.peeked.take() {
Option::Some(value) { value }
Option::None() { self.iter.next() }
Some(value) { value }
None() { self.iter.next() }
}
}

fn peek(self): Option<T> {
match self.peeked {
Option::Some(value) { value }
Option::None() {
self.peeked = Option::Some(value: self.iter.next())
Some(value) { value }
None() {
self.peeked = Some(self.iter.next())
self.peeked
}
}
Expand All @@ -28,7 +28,7 @@ pub trait PeekableAdapter<Self: Iter<T>, T> {

impl <T> PeekableAdapter<T> for Iter<T> {
fn peek<U>(self): PeekableIter<T> {
PeekableIter::PeekableIter(iter: self, peeked: Option::None())
PeekableIter(iter: self, peeked: None())
}
}

12 changes: 6 additions & 6 deletions src/std/list.no
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl <T> List<T> {

impl <T> Iterable<T> for List<T> {
fn iter(self): ListIter<T> {
ListIter::ListIter(list: self, index: 0)
ListIter(list: self, index: 0)
}
}

Expand All @@ -23,8 +23,8 @@ impl <T> Collector<T> for List<T> {
let list = []
while true {
match iter.next() {
Option::Some(value) { list.add(value) }
Option::None() { break }
Some(value) { list.add(value) }
None() { break }
}
}
list
Expand Down Expand Up @@ -58,11 +58,11 @@ pub type ListIter<T>(
impl <T> Iter<T> for ListIter<T> {
fn next(self): Option<T> {
match self.list.at(self.index) {
Option::Some(value) {
Some(value) {
self.index = self.index + 1
Option::Some(value)
Some(value)
}
_ { Option::None() }
_ { None() }
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/std/result.no
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ pub type Result<T, E> {
impl <T, E> Result<T, E> {
pub fn isOk(self): Bool {
match self {
Result::Ok() { true }
Ok() { true }
_ { false }
}
}
pub fn isError(self): Bool {
match self {
Result::Error() { true }
Error() { true }
_ { false }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/std/unit.no
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub type Unit()

pub let unit: Unit = Unit::Unit()
pub let unit: Unit = Unit()

0 comments on commit 8950314

Please sign in to comment.