From 0414bb5ac1bc5bf55e79c58370da984b91184ba6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 2 Jan 2025 15:06:17 -0600 Subject: [PATCH] refactor(manifest): Keep struct/impl close for easier viewing --- src/cargo/core/manifest.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index b1a54a8e43f..0273d8fa4d3 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -147,6 +147,24 @@ pub struct ManifestMetadata { pub rust_version: Option, } +impl ManifestMetadata { + /// Whether the given env var should be tracked by Cargo's dep-info. + pub fn should_track(env_key: &str) -> bool { + let keys = MetadataEnvs::keys(); + keys.iter().any(|k| *k == env_key) + } + + pub fn env_var<'a>(&'a self, env_key: &str) -> Option> { + MetadataEnvs::var(self, env_key) + } + + pub fn env_vars(&self) -> impl Iterator)> { + MetadataEnvs::keys() + .iter() + .map(|k| (*k, MetadataEnvs::var(self, k).unwrap())) + } +} + macro_rules! get_metadata_env { ($meta:ident, $field:ident) => { $meta.$field.as_deref().unwrap_or_default().into() @@ -193,24 +211,6 @@ metadata_envs! { (readme, "CARGO_PKG_README"), } -impl ManifestMetadata { - /// Whether the given env var should be tracked by Cargo's dep-info. - pub fn should_track(env_key: &str) -> bool { - let keys = MetadataEnvs::keys(); - keys.iter().any(|k| *k == env_key) - } - - pub fn env_var<'a>(&'a self, env_key: &str) -> Option> { - MetadataEnvs::var(self, env_key) - } - - pub fn env_vars(&self) -> impl Iterator)> { - MetadataEnvs::keys() - .iter() - .map(|k| (*k, MetadataEnvs::var(self, k).unwrap())) - } -} - #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub enum TargetKind { Lib(Vec),