Skip to content

Commit 1171917

Browse files
authored
Merge pull request #5125 from JackStouffer/isemail
Added attributes and usage of immutable to std.net.isemail
2 parents ee1bb66 + db5480c commit 1171917

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

std/net/isemail.d

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns
242242
else
243243
{
244244
contextPrior = context;
245-
auto c = token.front;
245+
immutable c = token.front;
246246

247247
if (c < '!' || c > '~' || c == '\n' || Token.specials.canFind(token))
248248
returnStatus ~= EmailStatusCode.errorExpectingText;
@@ -360,7 +360,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns
360360

361361
}
362362

363-
auto c = token.front;
363+
immutable c = token.front;
364364
hyphenFlag = false;
365365

366366
if (c < '!' || c > '~' || Token.specials.canFind(token))
@@ -414,7 +414,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns
414414
{
415415
auto ipV6 = addressLiteral.substr(5);
416416
matchesIp = ipV6.split(Token.colon);
417-
auto groupCount = matchesIp.length;
417+
immutable groupCount = matchesIp.length;
418418
index = ipV6.indexOf(Token.doubleColon);
419419

420420
if (index == -1)
@@ -487,7 +487,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns
487487
break;
488488

489489
default:
490-
auto c = token.front;
490+
immutable c = token.front;
491491

492492
if (c > AsciiToken.delete_ || c == '\0' || token == Token.openBracket)
493493
{
@@ -540,7 +540,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns
540540
break;
541541

542542
default:
543-
auto c = token.front;
543+
immutable c = token.front;
544544

545545
if (c > AsciiToken.delete_ || c == '\0' || c == '\n')
546546
returnStatus ~= EmailStatusCode.errorExpectingQuotedText;
@@ -555,7 +555,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns
555555
break;
556556

557557
case EmailPart.contextQuotedPair:
558-
auto c = token.front;
558+
immutable c = token.front;
559559

560560
if (c > AsciiToken.delete_)
561561
returnStatus ~= EmailStatusCode.errorExpectingQuotedPair;
@@ -623,7 +623,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns
623623
break;
624624

625625
default:
626-
auto c = token.front;
626+
immutable c = token.front;
627627

628628
if (c > AsciiToken.delete_ || c == '\0' || c == '\n')
629629
{
@@ -1280,7 +1280,7 @@ struct EmailStatus
12801280
* domainPart = the domain part of the email address
12811281
* statusCode = the status code
12821282
*/
1283-
private this (bool valid, string localPart, string domainPart, EmailStatusCode statusCode)
1283+
private this (bool valid, string localPart, string domainPart, EmailStatusCode statusCode) @safe @nogc pure nothrow
12841284
{
12851285
this.valid_ = valid;
12861286
this.localPart_ = localPart;
@@ -1289,37 +1289,37 @@ struct EmailStatus
12891289
}
12901290

12911291
/// Indicates if the email address is valid or not.
1292-
@property bool valid () const
1292+
@property bool valid() const @safe @nogc pure nothrow
12931293
{
12941294
return valid_;
12951295
}
12961296

12971297
/// The local part of the email address, that is, the part before the @ sign.
1298-
@property string localPart () const
1298+
@property string localPart() const @safe @nogc pure nothrow
12991299
{
13001300
return localPart_;
13011301
}
13021302

13031303
/// The domain part of the email address, that is, the part after the @ sign.
1304-
@property string domainPart () const
1304+
@property string domainPart() const @safe @nogc pure nothrow
13051305
{
13061306
return domainPart_;
13071307
}
13081308

13091309
/// The email status code
1310-
@property EmailStatusCode statusCode () const
1310+
@property EmailStatusCode statusCode() const @safe @nogc pure nothrow
13111311
{
13121312
return statusCode_;
13131313
}
13141314

13151315
/// Returns a describing string of the status code
1316-
@property string status () const
1316+
@property string status() const @safe @nogc pure nothrow
13171317
{
13181318
return statusCodeDescription(statusCode_);
13191319
}
13201320

13211321
/// Returns a textual representation of the email status
1322-
string toString () const
1322+
string toString() const @safe pure
13231323
{
13241324
import std.format : format;
13251325
return format("EmailStatus\n{\n\tvalid: %s\n\tlocalPart: %s\n\tdomainPart: %s\n\tstatusCode: %s\n}", valid,
@@ -1328,7 +1328,7 @@ struct EmailStatus
13281328
}
13291329

13301330
/// Returns a describing string of the given status code
1331-
string statusCodeDescription (EmailStatusCode statusCode)
1331+
string statusCodeDescription(EmailStatusCode statusCode) @safe @nogc pure nothrow
13321332
{
13331333
final switch (statusCode)
13341334
{

0 commit comments

Comments
 (0)