Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark the return type of methods such as Slice#copy_to as Nil #13774

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/slice.cr
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,14 @@ struct Slice(T)
super(range) { |i| yield i }
end

def copy_from(source : Pointer(T), count)
def copy_from(source : Pointer(T), count) : Nil
check_writable
check_size(count)

@pointer.copy_from(source, count)
end

def copy_to(target : Pointer(T), count)
def copy_to(target : Pointer(T), count) : Nil
check_size(count)

@pointer.copy_to(target, count)
Expand All @@ -513,7 +513,7 @@ struct Slice(T)
# dst # => Slice['a', 'a', 'a', 'b', 'b']
# dst.copy_to src # raises IndexError
# ```
def copy_to(target : self)
def copy_to(target : self) : Nil
target.check_writable
raise IndexError.new if target.size < size

Expand All @@ -524,18 +524,18 @@ struct Slice(T)
#
# Raises `IndexError` if the destination slice cannot fit the data being transferred.
@[AlwaysInline]
def copy_from(source : self)
def copy_from(source : self) : Nil
source.copy_to(self)
end

def move_from(source : Pointer(T), count)
def move_from(source : Pointer(T), count) : Nil
check_writable
check_size(count)

@pointer.move_from(source, count)
end

def move_to(target : Pointer(T), count)
def move_to(target : Pointer(T), count) : Nil
@pointer.move_to(target, count)
end

Expand All @@ -554,7 +554,7 @@ struct Slice(T)
# ```
#
# See also: `Pointer#move_to`.
def move_to(target : self)
def move_to(target : self) : Nil
target.check_writable
raise IndexError.new if target.size < size

Expand All @@ -566,7 +566,7 @@ struct Slice(T)
#
# Raises `IndexError` if the destination slice cannot fit the data being transferred.
@[AlwaysInline]
def move_from(source : self)
def move_from(source : self) : Nil
source.move_to(self)
end

Expand Down