Skip to content

Commit

Permalink
implement for std::net::IpAddr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vmagro authored and facebook-github-bot committed Sep 9, 2024
1 parent a1a432a commit 790c04f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions allocative/src/impls/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod cell;
mod collections;
mod function;
mod mem;
mod net;
mod primitive;
mod sync;
mod time;
Expand Down
33 changes: 33 additions & 0 deletions allocative/src/impls/std/net.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/

use std::net::IpAddr;
use std::net::Ipv4Addr;
use std::net::Ipv6Addr;

use crate::allocative_trait::Allocative;
use crate::visitor::Visitor;

impl Allocative for IpAddr {
fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) {
visitor.enter_self_sized::<Self>().exit();
}
}

impl Allocative for Ipv4Addr {
fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) {
visitor.enter_self_sized::<Self>().exit();
}
}

impl Allocative for Ipv6Addr {
fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) {
visitor.enter_self_sized::<Self>().exit();
}
}

0 comments on commit 790c04f

Please sign in to comment.