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

[BUG]Code comment inconsistency #804

Open
YichiZhang0613 opened this issue Dec 12, 2024 · 1 comment · May be fixed by #812
Open

[BUG]Code comment inconsistency #804

YichiZhang0613 opened this issue Dec 12, 2024 · 1 comment · May be fixed by #812
Labels

Comments

@YichiZhang0613
Copy link

Describe the bug
In cursive-new-main/cursive-core/src/event.rs, the comment indicates that code should be panic when n == 0 while the code would not.

/// # Panics
    ///
    /// If `n == 0 || n > 12`
    pub fn from_f(n: u8) -> Key {
        match n {
            0 => Key::F0,
            1 => Key::F1,
            2 => Key::F2,
            3 => Key::F3,
            4 => Key::F4,
            5 => Key::F5,
            6 => Key::F6,
            7 => Key::F7,
            8 => Key::F8,
            9 => Key::F9,
            10 => Key::F10,
            11 => Key::F11,
            12 => Key::F12,
            _ => panic!("unknown function key: F{n}"),
        }
    }

To Reproduce
Key::from_f(0); That will not panic.

Expected behavior
The code should be consistent with comment.

Censebastian pushed a commit to Censebastian/cursive that referenced this issue Dec 23, 2024
@gyscos
Copy link
Owner

gyscos commented Jan 9, 2025

Hi, and thanks for the report!

Indeed, it looks like the comment is inaccurate, possibly written before a F0 key was added.

@YichiZhang0613 YichiZhang0613 linked a pull request Feb 25, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants