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

Add from_path() to Target #122

Merged
merged 1 commit into from
May 19, 2020
Merged

Add from_path() to Target #122

merged 1 commit into from
May 19, 2020

Conversation

zmrow
Copy link
Contributor

@zmrow zmrow commented May 14, 2020

Issue #, if available:
N/A

Description of changes:
This function allows you to get a Target object from a given Path, provided it is a file.

This code comes from a piece of tuftool/src/create.rs and will be wholesale removed from tuftool in an upcoming PR. I opted to split this small change up into its own PR as the upcoming changes are much much further reaching and this is small and easy to review.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@zmrow zmrow requested review from iliana and webern May 14, 2020 20:22
tough/src/schema/mod.rs Outdated Show resolved Hide resolved
tough/src/schema/error.rs Outdated Show resolved Hide resolved
tough/src/schema/error.rs Outdated Show resolved Hide resolved
This function allows one to get a Target object from a given
Path, provided it is a file.
@zmrow
Copy link
Contributor Author

zmrow commented May 15, 2020

Fixed up my booboo's

@@ -224,6 +228,45 @@ pub struct Target {
pub _extra: HashMap<String, Value>,
}

impl Target {
/// Given a path, returns a Target struct
pub fn from_path<P>(path: P) -> Result<Target>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should mention that I initially tried to implement TryFrom<AsRef<Path>> and ran into this Rust issue. After that, I didn't think this was worth it to implement TryFrom with String, Path, PathBuf, etc.

Copy link
Contributor

@webern webern left a comment

Choose a reason for hiding this comment

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

🍰

@zmrow zmrow merged commit abb33f5 into awslabs:develop May 19, 2020
@zmrow zmrow deleted the target-from-path branch May 19, 2020 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants