Skip to content

Note constructors are indirect. #41

Description

@Aidavdw

The readme.md still mentions the use of PitchClass to use construct a Note.

use rustmt::note::{Note,  PitchClass}
let note = Note::new(PitchClass::As, 4);

If I am not mistaken, this has since been renamed to PitchSymbol in the actual code. I wanted to update the readme, but the constructor has since been altered as well to now take a Pitch object instead. This was done in b7b277b.
This would make the required code for a constructor the following:

use rustmt::note::{Note,  PitchSymbol}
let note = Note::new(PitchSymbol::As.into(), 4);
// Alternatively, this also works.
let note = Note::new(Pitch::from(PitchSymbol::As), 4);

Having good constructors as part of the API is undoubtedly very important.
Though this changed new()has been (erroneously?) part of the API now for quite a while, I suggest the argument for Note::new() to be changed back to PitchSymbol to reflect original intent (and documentation), or that a new convenience constructor should be implemented for this common operation.
I believe this is much clearer, and requires one less mental step for users.

use rustmt::note::{Note,  PitchSymbol}
let note = Note::new(PitchSymbol::As, 4);

Alternatively, keep current Note::new() but add an additional Note::From_Symbol()

use rustmt::note::{Note,  PitchSymbol}
let note = Note::from_symbol(PitchSymbol::As, 4);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions