mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
document usage of marshal.to; fixes #3150
This commit is contained in:
@@ -280,6 +280,17 @@ proc `$$`*[T](x: T): string =
|
||||
|
||||
proc to*[T](data: string): T =
|
||||
## reads data and transforms it to a ``T``.
|
||||
runnableExamples:
|
||||
type
|
||||
Foo = object
|
||||
id: int
|
||||
bar: string
|
||||
|
||||
let x = Foo(id: 1, bar: "baz")
|
||||
# serialize
|
||||
let y = ($$x)
|
||||
# deserialize back to type 'Foo':
|
||||
let z = y.to[:Foo]
|
||||
var tab = initTable[BiggestInt, pointer]()
|
||||
loadAny(newStringStream(data), toAny(result), tab)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user