Skip to content

Commit

Permalink
Merge pull request #54 from Inkrementator/master
Browse files Browse the repository at this point in the history
Fix deprecation: preview=in
  • Loading branch information
schveiguy authored Sep 19, 2023
2 parents 3528c9c + e54622b commit b9b62cb
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 28 deletions.
3 changes: 3 additions & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ configuration "dip1000" {
dflags "-dip1000"
versions "DIP1000"
}
configuration "preview_in" {
dflags "-preview=in"
}
12 changes: 2 additions & 10 deletions src/std/io/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,14 @@ unittest
import std.array : Appender;
Appender!(char[]) buffer;

void old(const scope char[] line) @safe
{
buffer.put(line);
}

void new_(in char[] line) @system
void bufferSink(in char[] line) @system
{
buffer.put(line);
}

scope e = new IOException(String("Hello, World"));
e.toString(&old);
assert(buffer[] == "std.io.exception.IOException: Hello, World");

buffer.clear();
e.toString(&new_);
e.toString(&bufferSink);
assert(buffer[] == "std.io.exception.IOException: Hello, World");

buffer.clear();
Expand Down
4 changes: 2 additions & 2 deletions src/std/io/internal/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ nothrow pure @safe @nogc:
}

///
bool opEquals(in ref String s) scope const
bool opEquals(scope const ref String s) scope const
{
return this[] == s[];
}

///
int opCmp(in ref String s) const
int opCmp(scope const ref String s) const
{
return __cmp(this[], s[]);
}
Expand Down
20 changes: 10 additions & 10 deletions src/std/io/net/addr.d
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ struct SocketAddrIPv4
}

///
bool opEquals()(in auto ref SocketAddrIPv4 rhs) const @nogc
bool opEquals()(in SocketAddrIPv4 rhs) const @nogc
{
assert(sa.sin_family == AddrFamily.IPv4);
assert(rhs.sa.sin_family == AddrFamily.IPv4);
Expand Down Expand Up @@ -465,7 +465,7 @@ struct SocketAddrIPv6
}

///
bool opEquals()(in auto ref SocketAddrIPv6 rhs) const @nogc
bool opEquals()(in SocketAddrIPv6 rhs) const @nogc
{
assert(sa.sin6_family == AddrFamily.IPv6);
assert(rhs.sa.sin6_family == AddrFamily.IPv6);
Expand Down Expand Up @@ -595,7 +595,7 @@ version (Posix) struct SocketAddrUnix
}

///
bool opEquals()(in auto ref SocketAddrUnix rhs) const @nogc
bool opEquals()(in SocketAddrUnix rhs) const @nogc
{
assert(sa.sun_family == AddrFamily.UNIX);
assert(rhs.sa.sun_family == AddrFamily.UNIX);
Expand Down Expand Up @@ -678,7 +678,7 @@ struct SocketAddr
}

/// Construct generic SocketAddr from specific type `SocketAddrX`.
this(SocketAddrX)(in auto ref SocketAddrX addr) pure nothrow @trusted @nogc
this(SocketAddrX)(in SocketAddrX addr) pure nothrow @trusted @nogc
if (isSocketAddr!SocketAddrX)
{
import core.stdc.string : memcpy;
Expand Down Expand Up @@ -735,7 +735,7 @@ struct SocketAddr
}

///
bool opEquals(SocketAddrX)(in auto ref SocketAddrX rhs) pure nothrow const @trusted @nogc
bool opEquals(SocketAddrX)(in SocketAddrX rhs) pure nothrow const @trusted @nogc
{
if (family != rhs.family)
return false;
Expand Down Expand Up @@ -848,17 +848,17 @@ else version (Windows)
private:

// Won't actually fail with proper buffer size and typed addr, so it'll never set errno and is actually pure
alias pure_inet_ntop = extern (System) const(char)* function(int, in void*, char*, socklen_t) pure nothrow @nogc;
alias pure_inet_ntop = extern (System) const(char)* function(int,scope const(void)*, char*, socklen_t) pure nothrow @nogc;
// Won't actually fail with proper addr family, so it'll never set errno and is actually pure
alias pure_inet_pton = extern (System) int function(int, in char*, void*) pure nothrow @nogc;
alias pure_inet_pton = extern (System) int function(int, scope const(char)*, void*) pure nothrow @nogc;

version (Windows)
{
extern (Windows) const(char)* inet_ntop(int, in void*, char*, size_t) nothrow @nogc;
extern (Windows) int inet_pton(int, in char*, void*) nothrow @nogc;
}

const(char)[] ipToString(in ref in_addr addr, return ref char[INET_ADDRSTRLEN] buf) pure nothrow @nogc @trusted
const(char)[] ipToString(in in_addr addr, return ref char[INET_ADDRSTRLEN] buf) pure nothrow @nogc @trusted
{
import core.stdc.string : strlen;

Expand All @@ -869,7 +869,7 @@ const(char)[] ipToString(in ref in_addr addr, return ref char[INET_ADDRSTRLEN] b
return p[0 .. strlen(p)];
}

const(char)[] ipToString(in ref in6_addr addr, return ref char[INET6_ADDRSTRLEN] buf) pure nothrow @nogc @trusted
const(char)[] ipToString(in in6_addr addr, return ref char[INET6_ADDRSTRLEN] buf) pure nothrow @nogc @trusted
{
import core.stdc.string : strlen;

Expand Down Expand Up @@ -906,7 +906,7 @@ bool stringToIP(S)(S s, ref in6_addr addr) /*pure*/ nothrow @nogc @trusted
return res == 1;
}

version (Posix) ubyte SUN_LEN(in ref sockaddr_un sun) pure nothrow @nogc @trusted
version (Posix) ubyte SUN_LEN(in sockaddr_un sun) pure nothrow @nogc @trusted
{
static if (is(typeof(sun.sun_len)))
return cast(ubyte)(sun.sun_path.offsetof + sun.sun_len);
Expand Down
4 changes: 2 additions & 2 deletions src/std/io/net/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ struct Socket
See_also: http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html
Throws: `ErrnoException` if binding the socket fails
*/
void bind(SocketAddr)(in auto ref SocketAddr addr) @trusted
void bind(SocketAddr)(in SocketAddr addr) @trusted
if (isSocketAddr!SocketAddr)
{
driver.bind(s, addr.cargs[]);
Expand Down Expand Up @@ -219,7 +219,7 @@ struct Socket
Params:
addr = socket address to connect to
*/
void connect(SocketAddr)(in auto ref SocketAddr addr) @trusted
void connect(SocketAddr)(in SocketAddr addr) @trusted
if (isSocketAddr!SocketAddr)
{
driver.connect(s, addr.cargs[]);
Expand Down
4 changes: 2 additions & 2 deletions src/std/io/net/tcp.d
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct TCP
addr = socket address to bind
backlog = maximum number of pending connections
*/
static TCPServer server(SocketAddr)(in auto ref SocketAddr addr, uint backlog = 128)
static TCPServer server(SocketAddr)(in SocketAddr addr, uint backlog = 128)
if (isSocketAddr!SocketAddr)
{
auto sock = Socket(addr.family, SocketType.stream, Protocol.default_);
Expand Down Expand Up @@ -196,7 +196,7 @@ struct TCP
Params:
addr = remote socket address to connect to
*/
static TCP client(SocketAddr)(in auto ref SocketAddr addr) @trusted
static TCP client(SocketAddr)(in SocketAddr addr) @trusted
if (isSocketAddr!SocketAddr)
{
auto sock = Socket(addr.family, SocketType.stream, Protocol.default_);
Expand Down
4 changes: 2 additions & 2 deletions src/std/io/net/udp.d
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct UDP
Params:
addr = socket address to bind
*/
static UDP server(SocketAddr)(in auto ref SocketAddr addr)
static UDP server(SocketAddr)(in SocketAddr addr)
if (isSocketAddr!SocketAddr)
{
auto res = UDP(addr.family);
Expand Down Expand Up @@ -216,7 +216,7 @@ struct UDP
Params:
addr = remote socket address to connect to
*/
static UDP client(SocketAddr)(in auto ref SocketAddr addr) @trusted
static UDP client(SocketAddr)(in SocketAddr addr) @trusted
if (isSocketAddr!SocketAddr)
{
auto res = UDP(addr.family);
Expand Down

0 comments on commit b9b62cb

Please sign in to comment.