You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Infer return types as sendable for mutable methods
In addition to inferring return types as sendable for immutable methods,
we now do the same for mutable methods _if and only if_ it's guaranteed
the receiver won't be able to store _any_ aliases (i.e. borrows). When
working with files and sockets (and similar types) this makes it easier
to work with mutating methods, removing the need for manually recovering
the values to owned values and then recovering them back to unique
values. For example, it's now possible to write this:
import std.fs.file (WriteOnlyFile)
let file = recover WriteOnlyFile.new('/tmp/test.txt'.to_path).get
file.write_string('hello').get
Prior to this commit this wouldn't be possible as `write_string` is a
mutable method, requiring you to write something along the lines of this
instead:
import std.fs.file (WriteOnlyFile)
let mut file = recover {
WriteOnlyFile.new('/tmp/test.txt'.to_path).get
}
file = recover {
let file = recover file
file.write_string('hello').get
file
}
This fixes#589.
Changelog: added
# uni_with_mutable_methods.inko:42:21 error(invalid-call): the receiver of this call requires a sendable return type, but 'Result[Int, String]' isn't sendable
0 commit comments