the stdlib supports &= in more contexts; refs #3524

This commit is contained in:
Andreas Rumpf 2016-03-05 16:13:23 +01:00
commit cc925d97f4
3 changed files with 10 additions and 0 deletions

View file

@ -895,6 +895,10 @@ proc send*(socket: Socket, data: string,
if sent != data.len:
raiseOSError(osLastError(), "Could not send all data.")
template `&=`*(socket: Socket; data: typed) =
## an alias for 'send'.
send(socket, data)
proc trySend*(socket: Socket, data: string): bool {.tags: [WriteIOEffect].} =
## Safe alternative to ``send``. Does not raise an EOS when an error occurs,
## and instead returns ``false`` on failure.