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

rework api #2

Open
Luro02 opened this issue Oct 30, 2019 · 0 comments
Open

rework api #2

Luro02 opened this issue Oct 30, 2019 · 0 comments
Milestone

Comments

@Luro02
Copy link
Owner

Luro02 commented Oct 30, 2019

Currently the api of a sub_cursor is like this

SubCursor::new() // empty SubCursor

and

let sub_cursor = SubCursor::from(Cursor::new(vec![]))
    .start(5)
    .end(100)
    .preserve(false);

Fields can only be accessed by calling get_end or get_start, which looks ugly

The new api should be

let sub_cursor = SubCursor::builder()
    .start(5)
    .end(100)
    .preserve(false)
    .build(Cursor::new(vec![1, 2, 3])?;

assert_eq!(sub_cursor.end(), 100);
assert_eq!(sub_cursor.start(), 5);

// setter
sub_cursor.set_start(value);
sub_cursor.set_end(value);

The new signature of SubCursor::new()

SubCursor::new(cursor: T, start: usize, end: usize, preserve: bool);
@Luro02 Luro02 added this to the 0.1.0 milestone Dec 9, 2019
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

1 participant