Conversation
|
Thanks for your pull request and interest in making D better, @denizzzka! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
|
I am should use git squash or this is not necessary? |
|
Yes do squash. Don't worry about the formatting, see #6220 |
FWIW: This is something different. Now back to the PR in question, is there any reason why you didn't add a writer-based @JackStouffer has been working hard on adding writer-based |
|
Sorry @denizzzka, I've been busy with other work the past few days and did not have time to properly review this. As @wilzbach pointed out, it would be preferably to add a writer-based overload of |
cfcf33b to
de8af2e
Compare
|
Changed for writer support and squashed |
| } | ||
|
|
||
| /// ditto | ||
| string toString() |
There was a problem hiding this comment.
This overload should be documented and considered the "primary" one, with the other just marked as "ditto". Explain that this forwards to the wrapped value and the results between <base type value>.to!string() and <Typedef'd type value>.to!string() will be identical.
There was a problem hiding this comment.
I do not know how to describe this beautifully, just added an example.
std/typecons.d
Outdated
| * fmt = A $(REF FormatSpec, std,format) which is used to represent | ||
| * the value | ||
| * Returns: | ||
| * A `string` if `writer` and `fmt` are not set; `void` otherwise. |
There was a problem hiding this comment.
This is incorrect, as each overload will show up separately in the documentation, and it will confuse readers if you say that this one could return void or string.
There was a problem hiding this comment.
(This is copy and paste from Nullable, so its documentation is weak too)
std/typecons.d
Outdated
| assert(s2 == cs2); | ||
| } | ||
|
|
||
| @safe unittest // toString |
There was a problem hiding this comment.
More unit tests are needed that test both overloads of toString with multiple different types of values.
Another good test to add would be something like the following to be reasonably sure that the results of Typedef.toString are the same as the base type:
import std.meta: AliasSeq;
import std.conv;
struct TestS {}
class TestC {}
static foreach (T; AliasSeq!(int, bool, float, double, real, ifloat, idouble, ireal,
cfloat, cdouble, creal, char, dchar, wchar, TestS,
TestC, int*, int[], int[2], int[int]))
{{
T t;
Typedef!T td
assert(t.to!string() == td.to!string());
}}
|
Something strange with CI check |
|
Not too strange though. |
12adf22 to
636a0f9
Compare
|
Oh, thank you, did not noticed by myself. |
|
Thanks @denizzzka! |
It is need to avoid silent conversion of Typedef struct itself to string by std.conv.to.
Discussion:
https://forum.dlang.org/post/kjzayldqnixehfprgslc@forum.dlang.org
Previous attempt: #6217