Try online at: https://run.dlang.io/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /+ | |
| Copy Constructor — Minimal Overload Set (15 overloads) | |
| ====================================================== | |
| Tests all 25 source × target qualifier combinations using | |
| only 3 source groups × 5 target qualifiers = 15 overloads. | |
| Target | |
| Source │ mut │ const │ immut │ shared │ sh.const │ | |
| ──────────────┼──────┼───────┼───────┼────────┼──────────┤ | |
| mutable │ G1 │ G1 │ G1 │ G1 │ G1 │ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum int[] x = [4, 3, 8, 10]; | |
| enum int[] y = imported!`std.algorithm`.sort(x).release; | |
| void main() | |
| { | |
| int[] z = y; | |
| imported!`std.stdio`.writeln(z); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Zero = []; | |
| type NN = number[]; | |
| type GetNN<N extends NN> = N['length']; | |
| type NextNN<N extends NN> = [...N, N['length']]; | |
| type PrevNN<N extends NN> = N extends [...infer Init, infer _] ? Init : never; | |
| type EqualNN<A extends NN, B extends NN> = | |
| GetNN<A> extends GetNN<B> ? true : false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import core.thread : thread_joinAll, Thread, ThreadGroup, Fiber; | |
| import std.stdio : writefln; | |
| void main() | |
| { | |
| writefln("Running on the main thread with id: '%s'", Thread.getThis().id); | |
| auto fiber = new Fiber(() { | |
| writefln("[before suspend] Running inside fiber on thread id '%s'", Thread.getThis().id); | |
| Fiber.yield(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while IFS="" read -r line; do | |
| project_path=$(echo "$line" | sed -E 's"(git@|.+://)[^:/]+[:/](.+)/.+$"\2"') | |
| repo_name=$(echo "$line" | sed -E -e 's|.+/(.+)$|\1|' -e 's|(.+)(.git)$|\1|') | |
| echo "* '$line'" | |
| echo " * '$project_path'" | |
| echo " * '$repo_name'" | |
| echo | |
| done < ./example_urls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface ICallable | |
| { | |
| void opCall() const; | |
| } | |
| auto makeDelegate(alias fun, Args...)(auto ref Args args) | |
| { | |
| return new class(args) ICallable | |
| { | |
| Args m_args; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void genericToString(T, Writer)(scope ref const T obj, scope ref Writer writer) | |
| { | |
| import std.format : formattedWrite; | |
| writer.formattedWrite("Transaction {\n"); | |
| writer.formattedWrite!" from: 0x%s\n"(obj.from.chars); | |
| writer.formattedWrite!" to: 0x%s\n"(obj.to.chars); | |
| writer.formattedWrite("}"); | |
| } |
NewerOlder