Skip to content

Commit

Permalink
std/io: add Discard
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Feb 18, 2025
1 parent b89a36d commit 7e2fe95
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions std/io/io.jule
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ trait Stream {
Closer
}

struct discard{}

impl Writer for discard {
fn Write(mut self, buf: []byte)!: (n: int) {
ret len(buf)
}
}

impl StrWriter for discard {
fn WriteStr(mut self, s: str)!: (n: int) {
ret len(s)
}
}

// A [Writer] on which all Write calls succeed without doing anything.
static mut Discard = discard{}

// Copy copies from src to dst until either EOF is reached
// on src or an error occurs. It returns the number of bytes
// copied and the first error encountered while copying, if any.
Expand Down

0 comments on commit 7e2fe95

Please sign in to comment.