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

Reintroducing the type parameter on Options (previously known as Wrapper). #215

Merged
merged 2 commits into from
Nov 9, 2020

Commits on Nov 9, 2020

  1. Reintroducing the type parameter on Options (previously Wrapper).

    This commit reverts the internal changes of mgeisler#206, but keeps the public API
    compatible to what it introduced. Essetially by adding a default for the
    type parameter.
    
    However, now in addition to the dynamic dispatch by default,
    one may also explicitly use static dispatch by specifying the type parameter.
    This now allows to construct an `Options` instance in const/static context.
    Which is further facilitated by adding the const fn `with_splitter`.
    
    Also, since `Options` now may be some specific type the `Clone` derive is added
    again. So when `S` is `Clone` then `Options` is `Clone` too.
    
    This change is actually backwards compatible with the previous commit,
    as seen by the unchanged examples and tests.
    Cryptjar committed Nov 9, 2020
    Configuration menu
    Copy the full SHA
    0d3c9d0 View commit details
    Browse the repository at this point in the history
  2. Switch to static dispatch by default.

    This commit essentially changes the return type of `Options::new` from
    `Options<Box<dyn WordSplitter>>` to `Options<HyphenSplitter>`, also making
    it a `const fn` in the process.
    
    Also the `Options::splitter` method is changed in order to allow returning
    a `Options` with a different type parameter, which is sort of necessary for
    static dispatch. However, this also allows to change to dynamic dispatch.
    This also make the `Options::new(w).splitter(s)` combination consistently
    equivalent to `Options::with_splitter(w, s)`, tho only the latter is a
    `const fn`.
    
    Also test cases have been adapted to favor static dispatch.
    Cryptjar committed Nov 9, 2020
    Configuration menu
    Copy the full SHA
    7892add View commit details
    Browse the repository at this point in the history