-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generic to should work instead of non-generic ofInt etc #10
Comments
The You can provide your own overloaded template to(b: BsonBase, typ: typedesc): untyped =
var r: typ = b
r
let b5 = 5.toBson
let i5 = b5.to(int)
doAssert i5 == 5 Note that we can immediately I don't think will add this to the lib, should this be added as example instead? |
@mashingan
operators do make sense in certain situations like std/wrapnils because of technical reasons (operator precedence), I can give more details and point to relevant discussion if needed. I really like the previous
this is a stretch ;-) it looks like you did that to avoid the parens in bson({ insertId: 8})
=>
!>{ insertId: 8} but the parens don't seem needed even with non operators, eg: import std/json
template foo(t: untyped): untyped = %* t
let s = foo {"a1": 12}
echo s.pretty |
the
Haha, maybe I can revert this but I'll see for several releases whether this is really convenient or just my misunderstanding. |
that's because you need a space, this works and is what I'm using: bson { insertId: 8} unless I'm missing something, I'd recommend to just use |
Reasonable, I don't want to add more aliases and the |
The text was updated successfully, but these errors were encountered: