Skip to content

Commit 790c04f

Browse files
vmagrofacebook-github-bot
authored andcommitted
implement for std::net::IpAddr
Summary: I want to wrap `IpAddr` in a following diff, so I'm implementing `Allocative` to make that more natural. Reviewed By: pallotron Differential Revision: D62303400 fbshipit-source-id: da973460b78ca7b980dc60aca5364aa8f09fce19
1 parent a1a432a commit 790c04f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

allocative/src/impls/std.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod cell;
1212
mod collections;
1313
mod function;
1414
mod mem;
15+
mod net;
1516
mod primitive;
1617
mod sync;
1718
mod time;

allocative/src/impls/std/net.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under both the MIT license found in the
5+
* LICENSE-MIT file in the root directory of this source tree and the Apache
6+
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
7+
* of this source tree.
8+
*/
9+
10+
use std::net::IpAddr;
11+
use std::net::Ipv4Addr;
12+
use std::net::Ipv6Addr;
13+
14+
use crate::allocative_trait::Allocative;
15+
use crate::visitor::Visitor;
16+
17+
impl Allocative for IpAddr {
18+
fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) {
19+
visitor.enter_self_sized::<Self>().exit();
20+
}
21+
}
22+
23+
impl Allocative for Ipv4Addr {
24+
fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) {
25+
visitor.enter_self_sized::<Self>().exit();
26+
}
27+
}
28+
29+
impl Allocative for Ipv6Addr {
30+
fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) {
31+
visitor.enter_self_sized::<Self>().exit();
32+
}
33+
}

0 commit comments

Comments
 (0)