Skip to content

Commit

Permalink
Merge pull request #2825 from ntrel/encode-docs
Browse files Browse the repository at this point in the history
Fix docs for encode overload
  • Loading branch information
andralex committed Dec 30, 2014
2 parents 3f942a2 + ebc3d2e commit 356c5e9
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions std/encoding.d
Expand Up @@ -1741,7 +1741,6 @@ body
Encodes $(D c) in units of type $(D E) and writes the result to the
output range $(D R). Returns the number of $(D E)s written.
*/

size_t encode(E, R)(dchar c, auto ref R range)
if (isNativeOutputRange!(R, E))
{
Expand Down Expand Up @@ -1841,6 +1840,26 @@ body
EncoderInstance!(E).encode(c,dg);
}

/**
Encodes the contents of $(D s) in units of type $(D Tgt), writing the result to an
output range.
Returns: The number of $(D Tgt) elements written.
Params:
Tgt = Element type of $(D range).
s = Input array.
range = Output range.
*/
size_t encode(Tgt, Src, R)(in Src[] s, R range)
{
size_t result;
foreach (c; s)
{
result += encode!(Tgt)(c, range);
}
return result;
}

/**
Returns a foreachable struct which can bidirectionally iterate over all
code points in a string.
Expand Down Expand Up @@ -1948,21 +1967,6 @@ unittest
assert(a[2] == 0xAC);
}

/**
Encodes $(D c) in units of type $(D E) and writes the result to the
output range $(D R). Returns the number of $(D E)s written.
*/

size_t encode(Tgt, Src, R)(in Src[] s, R range)
{
size_t result;
foreach (c; s)
{
result += encode!(Tgt)(c, range);
}
return result;
}

/**
Convert a string from one encoding to another.
Expand Down

0 comments on commit 356c5e9

Please sign in to comment.