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

tough: cache function should not take Option<GENERIC> #405

Open
webern opened this issue Aug 16, 2021 · 0 comments
Open

tough: cache function should not take Option<GENERIC> #405

webern opened this issue Aug 16, 2021 · 0 comments

Comments

@webern
Copy link
Contributor

webern commented Aug 16, 2021

Accepting an Option<T> as a function parameter is bad form because it means callers must specify a type (any type) when passing None.

targets_subset: Option<&[S]>,

The function should be changed from

    pub fn cache<P1, P2, S>(
        &self,
        metadata_outdir: P1,
        targets_outdir: P2,
        targets_subset: Option<&[S]>,
        cache_root_chain: bool,
    ) -> Result<()> {}

To either this:

    pub fn cache<P1, P2, S>(
        &self,
        metadata_outdir: P1,
        targets_outdir: P2,
        targets_subset: &[S],
        cache_root_chain: bool,
    ) -> Result<()> {}

Where is_empty means the same thing as is_none.

... or this

    pub fn cache<P1, P2, S>(
        &self,
        metadata_outdir: P1,
        targets_outdir: P2,
        targets_subset: Option<&[&str]>,
        cache_root_chain: bool,
    ) -> Result<()> {}

If is_empty and None need to carry different meanings.

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

No branches or pull requests

1 participant