method TVar.swap
Sets the value and returns the previous one.
Example:
use std.stm { TVar }
fn main() io {
let v = TVar<i32>.new(1)
let old = atomic { v.swap(2) }
print("{old} {atomic { v.get() }}")
}Output
1 2
pub(api) fn swap(value: T) -> TSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
value | T |
Returns
T
Effects
none declared (pure unless the body says otherwise)
Defined in: std/stm/stm.oxl:141