Skip to content

Commit

Permalink
Add support for more packages to DeepSize
Browse files Browse the repository at this point in the history
  • Loading branch information
pmnoxx committed Nov 11, 2021
1 parent 0489bfb commit 90a1efc
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
**/*.rs.bk
Cargo.lock
.idea
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ arrayvec = { version = "^0.5", optional = true }
smallvec = { version = "^1", optional = true }
hashbrown = { version = "^0.9", optional = true }
chrono = { version = "^0.4", optional = true }
tokio = { version = "^1.1", optional = true, features = ["full"] }
actix = { version = "0.11.0", optional = true }

[dev-dependencies]
deepsize_derive = { path = "deepsize_derive", version = "0.1.1" }
Expand Down
27 changes: 26 additions & 1 deletion src/default_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ impl<T: DeepSizeOf> DeepSizeOf for core::cell::RefCell<T> {
}
}

#[cfg(feature = "std")]
mod std_time {
use std::time::Instant;
use crate::{Context, DeepSizeOf};

impl DeepSizeOf for Instant {
fn deep_size_of_children(&self, _context: &mut Context) -> usize {
0
}
}
}

#[cfg(feature = "std")]
mod std_net {
use std::net::SocketAddr;
use crate::{Context, DeepSizeOf};

impl DeepSizeOf for SocketAddr {
fn deep_size_of_children(&self, _context: &mut Context) -> usize {
0
}
}

}

#[cfg(feature = "std")]
mod std_sync {
use crate::{Context, DeepSizeOf};
Expand Down Expand Up @@ -183,7 +208,7 @@ macro_rules! deep_size_array {
// A year and a half later, still waiting
deep_size_array!(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32
26, 27, 28, 29, 30, 31, 32, 64, 65
);

macro_rules! deep_size_tuple {
Expand Down
24 changes: 24 additions & 0 deletions src/external_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,27 @@ mod chrono_impl {
{T: TimeZone} DateTime<T>, {T: TimeZone} Date<T>,
);
}

#[cfg(feature = "tokio")]
mod tokio_impl {
use tokio::net::TcpStream;
use crate::{Context, DeepSizeOf};

impl DeepSizeOf for TcpStream {
fn deep_size_of_children(&self, _context: &mut Context) -> usize {
0
}
}
}

#[cfg(feature = "actix")]
mod actix_impl {
use actix::Addr;
use crate::{Context, DeepSizeOf};

impl<T: actix::Actor> DeepSizeOf for Addr<T> {
fn deep_size_of_children(&self, _context: &mut Context) -> usize {
0
}
}
}

0 comments on commit 90a1efc

Please sign in to comment.