View source code
Display the source code in std/string.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.string.abbrev
Construct an associative array consisting of all
abbreviations that uniquely map to the strings in values
.
This is useful in cases where the user is expected to type in one of a known set of strings, and the program will helpfully autocomplete the string once sufficient characters have been entered that uniquely identify it.
Prototype
string[string] abbrev( string[] values ) pure @safe;
Example
import std.stdio; import std.string; void main() { static string[] list = [ "food", "foxy" ]; auto abbrevs = std.string.abbrev(list); foreach (key, value; abbrevs) { writefln("%s => %s", key, value); } }
produces the output:
fox => foxy food => food foxy => foxy foo => food
Authors
Walter Bright, Andrei Alexandrescu, and Jonathan M Davis