How can I cast Bson (vibe.d) to various struct types? The best
would be to get rid of the switch statement as well.
It works fine deserializing when casting directly
collection.findOne!UserCreate(), but when I try from a Bson
object I get below error directly.
What to do?
The error I get wh
I want to have a array/list/queue of instances of various struct
types that represent events. How can I achieve that? With classes
I would have interfaces I guess, but I want to use structs if
possible as they seem less complex (and faster?).
Can I wrap each struct with in another struct calle
On Wednesday, 18 December 2019 at 22:11:10 UTC, Sebastiaan Koppe
wrote:
If you know all types up front you can use the Sumtype library
on code.dlang.org
Thanks, it's a good starting point, the best would be if I only
needed to define that the struct would implement void applyTo(ref
User use
On Thursday, 19 December 2019 at 00:00:56 UTC, Paul Backus wrote:
If all of the structs need to implement a particular method (or
set of methods), you can use an interface and a templated
adapter class to give them a common type. Here's a simple
example:
Thank you for the example that looks l
On Thursday, 19 December 2019 at 00:00:56 UTC, Paul Backus wrote:
interface Action
{
void applyTo(ref User); <-- change to applyTo(T)(ref T)
}
class ActionAdapter(T) : Action
{
T payload;
this(T payload)
{
this.payload = payload;
}
override void applyTo(ref Use
On Thursday, 19 December 2019 at 21:26:51 UTC, Paul Backus wrote:
The reason this doesn't work is that interface methods are
virtual, and virtual methods can't be templates. [1] If you
want to have multiple kinds of entities, one option is to
create an Entity interface and EntityAdapter(T) cl
How can I initialize my two dimensional array?
When I try to run the code below I get the error:
Error: non-constant expression ["user":[cast(Capability)0],
"administrator":[cast(Capability)1]]
Code:
enum Capability {
self,
administer
}
alias Capabilities = immut
I'm experimenting with generating wasm files with ldc2 but I'm
having problems when trying to pass JavaScript Objects and
receive them as structs and the other way around.
I found this super nice getting started guide that works fine for
basic types like double and so on
https://wiki.dlang.or
On Wednesday, 24 June 2020 at 10:53:19 UTC, Sebastiaan Koppe
wrote:
On Tuesday, 23 June 2020 at 18:15:25 UTC, tirithen wrote:
[...]
Passing anything besides int/double/bool between JS and wasm is
hard work.
[...]
Thanks for a really good explanation, passing pointers over the
structs mat