Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove derive_more crate #1406

Merged
merged 2 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ arrow2 = "0.16"
arrow2_convert = "0.4.2"
clap = "4.0"
comfy-table = { version = "6.1", default-features = false }
derive_more = "0.99"
ecolor = "0.21.0"
eframe = { version = "0.21.3", default-features = false }
egui = "0.21.0"
Expand Down
1 change: 0 additions & 1 deletion crates/re_analytics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ re_log.workspace = true
# External dependencies:
anyhow.workspace = true
crossbeam = "0.8"
derive_more.workspace = true
once_cell = "1.17"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
36 changes: 32 additions & 4 deletions crates/re_analytics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ impl Event {
}
}

#[derive(Debug, Clone, derive_more::From, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum Property {
Bool(bool),
Integer(i64),
Float(f64),
String(String),
Bool(bool),
}

impl Property {
Expand All @@ -131,12 +131,40 @@ impl Property {
let mut hasher = sha2::Sha256::default();
hasher.update(SALT);
match self {
Property::Bool(data) => hasher.update([*data as u8]),
Property::Integer(data) => hasher.update(data.to_le_bytes()),
Property::Float(data) => hasher.update(data.to_le_bytes()),
Property::String(data) => hasher.update(data),
Property::Bool(data) => hasher.update([*data as u8]),
}
format!("{:x}", hasher.finalize()).into()
Self::String(format!("{:x}", hasher.finalize()))
}
}

impl From<bool> for Property {
#[inline]
fn from(value: bool) -> Self {
Self::Bool(value)
}
}

impl From<i64> for Property {
#[inline]
fn from(value: i64) -> Self {
Self::Integer(value)
}
}

impl From<f64> for Property {
#[inline]
fn from(value: f64) -> Self {
Self::Float(value)
}
}

impl From<String> for Property {
#[inline]
fn from(value: String) -> Self {
Self::String(value)
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/re_format/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ all-features = true
[dependencies]
arrow2.workspace = true
comfy-table.workspace = true
derive_more.workspace = true
1 change: 0 additions & 1 deletion crates/re_format/src/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl std::fmt::Display for DisplayIntervalUnit {
}

//TODO(john) move this and the Display impl upstream into arrow2
#[derive(derive_more::From, derive_more::Into)]
#[repr(transparent)]
pub struct DisplayDataType(DataType);

Expand Down
1 change: 0 additions & 1 deletion crates/re_log_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ chrono = { version = "0.4", features = [
"js-sys",
"wasmbind",
] } # TODO(emilk): replace `chrono` with `time` crate
derive_more.workspace = true
document-features = "0.2"
fixed = { version = "1.17", default-features = false, features = ["serde"] }
half = { workspace = true, features = ["bytemuck"] }
Expand Down
13 changes: 1 addition & 12 deletions crates/re_log_types/src/component_types/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@ use crate::msg_bundle::Component;
///
/// assert_eq!(ColorRGBA::data_type(), DataType::UInt32);
/// ```
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
derive_more::From,
derive_more::Into,
ArrowField,
ArrowSerialize,
ArrowDeserialize,
)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, ArrowField, ArrowSerialize, ArrowDeserialize)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[arrow_field(transparent)]
pub struct ColorRGBA(pub u32);
Expand Down
25 changes: 14 additions & 11 deletions crates/re_log_types/src/component_types/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@ use crate::msg_bundle::Component;
///
/// assert_eq!(Label::data_type(), DataType::Utf8);
/// ```
#[derive(
Debug,
Clone,
PartialEq,
Eq,
derive_more::From,
derive_more::Into,
ArrowField,
ArrowSerialize,
ArrowDeserialize,
)]
#[derive(Debug, Clone, PartialEq, Eq, ArrowField, ArrowSerialize, ArrowDeserialize)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[arrow_field(transparent)]
pub struct Label(pub String);
Expand All @@ -32,3 +22,16 @@ impl Component for Label {
"rerun.label".into()
}
}

impl From<String> for Label {
#[inline]
fn from(value: String) -> Self {
Self(value)
}
}

impl From<Label> for String {
fn from(value: Label) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline

value.0
}
}
11 changes: 1 addition & 10 deletions crates/re_log_types/src/component_types/radius.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@ use crate::msg_bundle::Component;
/// # use arrow2::datatypes::{DataType, Field};
/// assert_eq!(Radius::data_type(), DataType::Float32);
/// ```
#[derive(
Debug,
Clone,
Copy,
derive_more::From,
derive_more::Into,
ArrowField,
ArrowSerialize,
ArrowDeserialize,
)]
#[derive(Debug, Clone, Copy, ArrowField, ArrowSerialize, ArrowDeserialize)]
#[arrow_field(transparent)]
pub struct Radius(pub f32);

Expand Down
24 changes: 14 additions & 10 deletions crates/re_log_types/src/component_types/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ use crate::msg_bundle::Component;
/// # use arrow2::datatypes::{DataType, Field};
/// assert_eq!(Scalar::data_type(), DataType::Float64);
/// ```
#[derive(
Debug,
Clone,
Copy,
derive_more::From,
derive_more::Into,
ArrowField,
ArrowSerialize,
ArrowDeserialize,
)]
#[derive(Debug, Clone, Copy, ArrowField, ArrowSerialize, ArrowDeserialize)]
#[arrow_field(transparent)]
pub struct Scalar(pub f64);

Expand All @@ -34,6 +25,19 @@ impl Component for Scalar {
}
}

impl From<f64> for Scalar {
#[inline]
fn from(value: f64) -> Self {
Self(value)
}
}

impl From<Scalar> for f64 {
fn from(value: Scalar) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline

value.0
}
}

// ---

/// Additional properties of a scalar when rendered as a plot.
Expand Down
9 changes: 8 additions & 1 deletion crates/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl std::str::FromStr for RecordingId {
/// The user-chosen name of the application doing the logging.
///
/// Used to categorize recordings.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, derive_more::Display)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct ApplicationId(pub String);

Expand All @@ -146,6 +146,13 @@ impl ApplicationId {
}
}

impl std::fmt::Display for ApplicationId {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}

// ----------------------------------------------------------------------------

/// The most general log message sent from the SDK to the server.
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/view_time_series/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl SceneTimeSeries {
attrs: PlotPointAttrs {
label,
color,
radius: radius.map_or(DEFAULT_RADIUS, |r| r.into()),
radius: radius.map_or(DEFAULT_RADIUS, |r| r.0),
scattered: props.map_or(false, |props| props.scattered),
},
});
Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ wildcards = "allow" # at least until https://github.com/EmbarkStudios/cargo-deny
deny = [
{ name = "cgmath" }, # We use glam
{ name = "cmake" }, # Never again
{ name = "derive_more" }, # Is very slow to compile; see https://github.com/rerun-io/rerun/issues/1316
{ name = "egui_glow" }, # We use wgpu
{ name = "openssl-sys" }, # We prefer rustls
{ name = "openssl" }, # We prefer rustls
Expand Down