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

Fix entity_path_vec! and entity_path! depending on ToString being in scope. #4766

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
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
17 changes: 14 additions & 3 deletions crates/re_log_types/src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,32 @@ pub use parse_path::PathParseError;

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

/// Reexports for use by macros to avoid depending on the caller's namespacing.
#[doc(hidden)]
pub mod __private {
pub use ::std::{string, vec};
}

/// Build a `Vec<EntityPathPart>`:
/// ```
/// # #![no_std] // test that the macro does not depend on the std *prelude*
/// # extern crate std;
/// # fn main() {
/// # use std::vec::Vec;
/// # use re_log_types::*;
/// let parts: Vec<EntityPathPart> = entity_path_vec!("foo", 42, "my image!");
/// # }
/// ```
#[macro_export]
macro_rules! entity_path_vec {
() => {
// A vector of no elements that nevertheless has the expected concrete type.
::std::vec::Vec::<$crate::EntityPathPart>::new()
$crate::path::__private::vec::Vec::<$crate::EntityPathPart>::new()
};
($($part: expr),* $(,)?) => {
vec![ $($crate::EntityPathPart::from(
$crate::path::__private::vec![ $($crate::EntityPathPart::from(
#[allow(clippy::str_to_string, clippy::string_to_string)]
$part.to_string()
$crate::path::__private::string::ToString::to_string(&$part)
),)+ ]
};
}
Expand Down
Loading