Use UFCS for reducing dependencies

Hipreme msnmancini at hotmail.com
Mon Jul 18 10:40:23 UTC 2022


On Sunday, 17 July 2022 at 16:15:07 UTC, Paul Backus wrote:
>
> Another possibility:
>
> ```d
> struct PNG
> {
>     static PNG load(Source)(Source source)
>         if (isInputRange!Source && is(ElementType!Source == 
> ubyte))
>     {
>         // etc.
>     }
> }
> ```
>
> This way, the PNG module itself is completely agnostic about 
> what data source it loads from, and has no explicit 
> dependencies (except on `std.range`, I guess).


Could you extend it a bit further how would that work?


More information about the Digitalmars-d mailing list