Skip to content

Commit

Permalink
Remove return type restriction on IO#read implementations
Browse files Browse the repository at this point in the history
When it's not guaranteed that a wrapped IO returns `Int32`,
we can't use that restriction.
  • Loading branch information
straight-shoota committed Jun 28, 2021
1 parent acd6c47 commit 25b76da
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/digest/io_digest.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class IO::Digest < IO
def initialize(@io : IO, @digest_algorithm : ::Digest, @mode = DigestMode::Read)
end

def read(slice : Bytes) : Int32
def read(slice : Bytes)
read_bytes = io.read(slice)
if @mode.read?
digest_algorithm.update(slice[0, read_bytes])
Expand Down
6 changes: 3 additions & 3 deletions src/http/content.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module HTTP
class FixedLengthContent < IO::Sized
include Content

def read(slice : Bytes) : Int32
def read(slice : Bytes)
ensure_send_continue
super
end
Expand Down Expand Up @@ -58,7 +58,7 @@ module HTTP
def initialize(@io : IO)
end

def read(slice : Bytes) : Int32
def read(slice : Bytes)
ensure_send_continue
@io.read(slice)
end
Expand Down Expand Up @@ -112,7 +112,7 @@ module HTTP
@received_final_chunk = false
end

def read(slice : Bytes) : Int32
def read(slice : Bytes)
ensure_send_continue
count = slice.size
return 0 if count == 0
Expand Down
2 changes: 1 addition & 1 deletion src/io/argf.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class IO::ARGF < IO
@read_from_stdin = false
end

def read(slice : Bytes) : Int32
def read(slice : Bytes)
first_initialize unless @initialized

if current_io = @current_io
Expand Down
2 changes: 1 addition & 1 deletion src/io/hexdump.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IO::Hexdump < IO
def initialize(@io : IO, @output : IO = STDERR, @read = false, @write = false)
end

def read(buf : Bytes) : Int32
def read(buf : Bytes)
@io.read(buf).tap do |read_bytes|
buf[0, read_bytes].hexdump(@output) if @read && read_bytes
end
Expand Down
2 changes: 1 addition & 1 deletion src/io/sized.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IO::Sized < IO
@read_remaining = read_size.to_u64
end

def read(slice : Bytes) : Int32
def read(slice : Bytes)
check_open

count = {slice.size.to_u64, @read_remaining}.min
Expand Down
2 changes: 1 addition & 1 deletion src/io/stapled.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class IO::Stapled < IO
end

# Reads a slice from `reader`.
def read(slice : Bytes) : Int32
def read(slice : Bytes)
check_open

@reader.read(slice)
Expand Down

0 comments on commit 25b76da

Please sign in to comment.