mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
the stdlib supports &= in more contexts; refs #3524
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -3286,6 +3286,10 @@ proc `/=`*[T: float|float32](x: var T, y: T) {.inline, noSideEffect.} =
|
||||
x = x / y
|
||||
|
||||
proc `&=`* (x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.}
|
||||
template `&=`*(x, y: typed) = add(x, y)
|
||||
template `&=`*(f: File, x: typed) = write(f, x)
|
||||
## generic 'sink' operator for Nim. For files an alias for ``write``.
|
||||
## If not specialized further an alias for ``add``.
|
||||
|
||||
proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.}
|
||||
## converts the AST of `x` into a string representation. This is very useful
|
||||
|
||||
@@ -27,6 +27,8 @@ Library Additions
|
||||
|
||||
- The rlocks module has been added providing reentrant lock synchronization
|
||||
primitive.
|
||||
- A generic "sink operator" written as ``&=`` has been added to the ``system`` and the ``net`` modules.
|
||||
|
||||
|
||||
Compiler Additions
|
||||
------------------
|
||||
|
||||
Reference in New Issue
Block a user