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

Improve examples #221

Closed
zrzka opened this issue Sep 16, 2019 · 4 comments
Closed

Improve examples #221

zrzka opened this issue Sep 16, 2019 · 4 comments

Comments

@zrzka
Copy link
Contributor

zrzka commented Sep 16, 2019

Currently there're top level examples (crossterm) and examples in subcrates (crossterm_cursor/example). This is causing issues like:

  • I can't run subcrate examples with cargo run --example cc_cursor
  • Lot of duplicated code
  • Build warnings (examples with the same name)
    • Will be hard error in the future
    • I prefixed them in the 2018 edition #222 as a temporary workaround

My proposal is to:

  • Remove all subcrate examples
  • Improve top level examples (merge them with the subcrate ones)

This is based on the fact that most people will use crossterm crate only (with features) directly.

@zrzka zrzka mentioned this issue Sep 16, 2019
@zrzka
Copy link
Contributor Author

zrzka commented Sep 16, 2019

Reply from #222:

I'm really doubting that we might want to remove the examples from the sub crates and instead use those in /examples, because all those examples are mostly duplicated with the only difference being the namespaces.

IMHO this can be solved by splitting imports in the root level example and adding a comment that crossterm should be replaced with crossterm_... if a subcrate is used directly. What bothers me:

  • code duplication
  • you can't run subcrate examples with simple cargo run --example
  • it's not clear that these examples differ in the namespace only and when I saw them for the first time (directory structure, not the code itself) I thought that they're different

I'll show you what I mean with this issue & comment in a separate branch. I can delete it if you wont like it, no problem.

@TimonPost
Copy link
Member

Exactly I prefer that as well because code duplication is a real pain. Just comment in the /examples/README.md, or in the example file would be good enough to tell the user that namespaces might vary on the crate they are using.

@TimonPost
Copy link
Member

I am going to open a PR that removes all duplicated examples in subcrates

@zrzka
Copy link
Contributor Author

zrzka commented Sep 17, 2019

Fixed by #225

@zrzka zrzka closed this as completed Sep 17, 2019
december1981 pushed a commit to december1981/crossterm that referenced this issue Oct 26, 2023
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

2 participants