How to use template Object in interface?

zoujiaqing zoujiaqing at gmail.com
Tue Jun 25 12:21:59 UTC 2019


On Tuesday, 25 June 2019 at 12:11:47 UTC, zoujiaqing wrote:
> hunt-cache current version use template implemention adapter 
> changes.
>
> I want use Interface to define Adapter, this master code unable 
> to comple.
>
> How to do it? D programming language design flaws?
>
> ```bash
> git clone https://github.com/huntlabs/hunt-cache
> cd hunt-cache/example
> dub run -v
>
> ...
>
> source/app.d(29,19): Error: no property name for type 
> Nullable!(User)
>
> ```

Interface code:

https://github.com/huntlabs/hunt-cache/blob/master/source/hunt/cache/adapter/Adapter.d

```D
module hunt.cache.adapter.Adapter;

import hunt.cache.Nullable;

interface Adapter
{
     Nullable!V get(V) (string key);

     Nullable!V[string] get(V) (string[] keys);

     void set(V) (string key, V value, uint expired);

     void set(V) (V[string] maps, uint expired);

     bool setIfAbsent(V) (string key, V value);

     bool hasKey(string key);

     bool remove(string key);

     void remove(string[] keys);

     void clear();
}
```


More information about the Digitalmars-d-learn mailing list