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

Accept Vec and slice arguments to encode_polyline #7

Merged
merged 2 commits into from Jul 17, 2016

Conversation

urschrei
Copy link
Member

This is both more flexible and potentially more efficient, since slices require a single pointer dereference, and Vecs require two.

It also has the (potential) benefit of simplifying FFI interaction, since it's easier and more efficient to create slices than Vecs from pointers to data allocated outside Rust.

This is both more flexible and potentially more efficient,
since slices require a single pointer dereference, and Vecs require two.
@@ -38,17 +38,20 @@ fn encode(current: f64, previous: f64, factor: i32) -> Result<String, String> {
Ok(output)
}

/// Encodes a Google Encoded Polyline.
/// Encodes a Google Encoded Polyline. Accepts a Vec or slice
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually just accepts a slice. Since a Vec can Deref to a slice, the Vec is treated as a slice. Anything that can Deref to a slice (or a slice itself) can be passed as an argument.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Accepts a slice or anything (such as a vec) that can deref to a slice"? I'm just thinking of making it explicit for people who aren't necessarily aware of the exact relationship between the two.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@frewsxcv
Copy link
Member

@tmcw This pull request looks good to me? Can I merge or do you want to do so?

Tangentially, it looks like you're the only one with crates.io publish access for the library. If this is intentional, carry on. Otherwise, you can use cargo owner -a github:georust:core to allow others (including myself) in the GeoRust organization to publish new versions.

@tmcw
Copy link
Collaborator

tmcw commented Jul 17, 2016

👍 merging, feel free to merge @frewsxcv and just updated the crates to include the georust organization.

@tmcw tmcw merged commit fb740ec into georust:master Jul 17, 2016
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.

None yet

3 participants