assign2: string support (#81)
This commit is contained in:
parent
7d2790fdf4
commit
7fb220d1e8
|
@ -32,6 +32,10 @@ func assign*[T](tgt: var seq[T], src: openArray[T]) =
|
|||
tgt.setLen(src.len)
|
||||
assignImpl(tgt.toOpenArray(0, tgt.high), src)
|
||||
|
||||
func assign*(tgt: var string, src: string) =
|
||||
tgt.setLen(src.len)
|
||||
assignImpl(tgt.toOpenArrayByte(0, tgt.high), src.toOpenArrayByte(0, tgt.high))
|
||||
|
||||
macro unsupported(T: typed): untyped =
|
||||
error "Assignment of the type " & humaneTypeName(T) & " is not supported"
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ suite "assign2":
|
|||
a = 5
|
||||
b = [2, 3]
|
||||
c = @[5, 6]
|
||||
d = "hello"
|
||||
|
||||
assign(c, b)
|
||||
check: c == b
|
||||
|
@ -21,6 +22,9 @@ suite "assign2":
|
|||
assign(c.toOpenArray(0, 1), [2, 2])
|
||||
check: c == [2, 2]
|
||||
|
||||
assign(d, "there!")
|
||||
check: d == "there!"
|
||||
|
||||
var
|
||||
dis = X(53)
|
||||
|
||||
|
|
Loading…
Reference in New Issue