from

Used as entry point for local imports.

enum from = FromImpl!null();

Examples

Test things that should work.

// use a function from standard library directly.
from.std.stdio.writeln("Hallo");
// assign something from standard library to a local variable.
auto _ = from.std.datetime.stopwatch.AutoStart.yes;

Test that calling a nonexistent function with a string throws with a useful message.

import std.algorithm.searching : canFind;

auto throws = false;
uint containsInfo;
try {
    from.std.stdio.thisFunctionDoesNotExist("Hallo");
} catch (Exception ex) {
    throws = true;
    containsInfo = canFind(ex.msg, "stdio", "thisFunctionDoesNotExist");
}

assert(throws);
assert(containsInfo == 2);

Test that calling a nonexistent function with a number throws with a useful message.

import std.algorithm.searching : canFind;

auto throws = false;
uint containsInfo;
try {
    from.std.stdio.thisFunctionDoesNotExist(42);
    throws = false;
} catch (Exception ex) {
    throws = true;
    containsInfo = canFind(ex.msg, "stdio", "thisFunctionDoesNotExist");
}

assert(throws);
assert(containsInfo == 2);

Meta