-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Changed some load_rustdoc arguments to a struct #347
Changed some load_rustdoc arguments to a struct #347
Conversation
Self::Registry { crate_ } => crate_.features().keys().cloned().into_iter().collect(), | ||
Self::ManifestPath { manifest } => manifest | ||
.parsed | ||
.features | ||
.keys() | ||
.cloned() | ||
.into_iter() | ||
.collect(), | ||
Self::Registry { crate_ } => crate_.features().keys().cloned().collect(), | ||
Self::ManifestPath { manifest } => manifest.parsed.features.keys().cloned().collect(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was made, because the new clippy complains.
impl<'a> ToString for CrateType<'a> { | ||
fn to_string(&self) -> String { | ||
match self { | ||
CrateType::Current => "current", | ||
CrateType::Baseline { .. } => "baseline", | ||
} | ||
.to_string() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wasteful to create a String
when it could be &'static str
-- is there a way to do it with this trait, or should I for example remove this trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I merged out of order. In #348 I made this a regular method returning &'static str
since we don't actually care about ToString
as a trait by itself (we'll never write impl ToString
and mean this type).
src/baseline.rs
Outdated
pub(crate) enum CrateType<'a> { | ||
Current, | ||
Baseline { | ||
/// When the baseline is being generated from registry | ||
/// and no specific version was chosen, we want to select a version | ||
/// that is the same or older than the version of the current crate. | ||
highest_allowed_version: Option<&'a semver::Version>, | ||
}, | ||
} | ||
|
||
pub(crate) struct CrateDataForRustdoc<'a> { | ||
pub(crate) crate_type: CrateType<'a>, | ||
pub(crate) name: &'a str, | ||
// TODO: pass an enum describing which features to enable | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether I like all the names here -- do you have some better ideas @obi1kenobi ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're ... okay. I don't love them either but none of my ideas are substantially better, and we need this feature much more than we need fancy names here. These will do for now.
Accidentally merged out of order, so these changes got merged in #348. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to stop #348 from merging out of order, so let's do this properly 😅
This PR is a continuation of #341 and #340.
It doesn't yet introduce functional changes -- the only change is that I've defined some new enums/structs and I'm passing them to
load_rustdoc
functions, instead of several arguments.The reasoning is that some arguments were not obvious / should have been documented, but it's hard to do it near each
load_rustdoc
function. It's also convenient to group those struct fields together -- they are strictly related and independent of otherload_rustdoc
arguments. The new enum allows to execute the new rustdoc generation through the placeholder for the current crate (which will be done in a next PR). The struct also allows for an easier additive change in some next PR, which will add the possibility of choosing which features to enable.