Skip to content

Make everything const #16

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

Closed
wants to merge 0 commits into from
Closed

Make everything const #16

wants to merge 0 commits into from

Conversation

TheBotlyNoob
Copy link
Contributor

similar to #15, but it makes more things const.

@thejpster
Copy link
Member

I don't think we need to take _layout: T, _set: S as args - they can be specified using a turbofish.

@thejpster
Copy link
Member

I merged a PR that adds Github Actions support (I don't think Travis CI works any more for free projects) so could you rebase on that?

@thejpster
Copy link
Member

I also had a play with the turbofish idea:

  16   │ --- a/src/lib.rs
  17   │ +++ b/src/lib.rs
  18   │ @@ -314,7 +314,7 @@ where
  19   │      S: ScancodeSet,
  20   │  {
  21   │      /// Make a new Keyboard object with the given layout.
  22   │ -    pub fn new(_layout: T, _set: S, handle_ctrl: HandleControl) -> Keyboard<T, S> {
  23   │ +    pub const fn new(handle_ctrl: HandleControl) -> Keyboard<T, S> {
  24   │          Keyboard {
  25   │              register: 0,
  26   │              num_bits: 0,
  27   │ @@ -564,9 +564,7 @@ mod test {
  28   │  
  29   │      #[test]
  30   │      fn test_f9() {
  31   │ -        let mut k = Keyboard::new(
  32   │ -            layouts::Us104Key,
  33   │ -            ScancodeSet2,
  34   │ +        let mut k: Keyboard<layouts::Us104Key, ScancodeSet2> = Keyboard::new(
  35   │              HandleControl::MapLettersToUnicode,
  36   │          );
  37   │          // start

@TheBotlyNoob
Copy link
Contributor Author

whoops.

@TheBotlyNoob
Copy link
Contributor Author

could you reopen the pr?

@thejpster
Copy link
Member

No it won't let me. This might be because you closed it. Open another?

Also - pro tip: don't work on the main branch in your fork otherwise your fork will always have commits upstream does not. Instead, always do the work in a branch and open a PR from there. This will also make rebasing easier.

@TheBotlyNoob
Copy link
Contributor Author

Okay, thanks for the tip. I'm not very experienced at git.

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.

2 participants