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

Upgrade rust library dependencies and bump version #422

Merged
merged 3 commits into from Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions rust/Cargo.toml
@@ -1,15 +1,15 @@
[package]
name = "open-location-code"
description = "Library for translating between GPS coordinates (WGS84) and Open Location Code"
version = "0.1.0"
version = "0.2.0"
authors = ["James Fysh <james.fysh@gmail.com>"]
license = "Apache-2.0"
repository = "https://github.com/google/open-location-code"
keywords = ["geography", "geospatial", "gis", "gps", "olc"]
exclude = ["rust.iml"]

[dependencies]
geo = "^0.4.3"
geo = "0.16.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is effectively dropping support for versions < 0.16.0, right? Can you add some description of why that's desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rust uses a slightly weird variant of semver so versions 0.4.x, 0.5.x, .... 0.16.x, 1.x.y, 2.x.y are all mutually incompatible (you can see more details here). The net result is that previously the library only supported versions 0.4.x and after this change will support only 0.16.x.


[dev-dependencies]
rand = "^0.6.5"
rand = "0.8.0"
2 changes: 1 addition & 1 deletion rust/src/interface.rs
Expand Up @@ -307,7 +307,7 @@ pub fn recover_nearest(code: &str, ref_pt: Point<f64>) -> Result<String, String>
}

let prefix_len = SEPARATOR_POSITION - code.find(SEPARATOR).unwrap();
let mut code = prefix_by_reference(ref_pt, prefix_len) + code;
let code = prefix_by_reference(ref_pt, prefix_len) + code;

let code_area = decode(code.as_str()).unwrap();

Expand Down
6 changes: 3 additions & 3 deletions rust/tests/all_test.rs
Expand Up @@ -136,9 +136,9 @@ fn benchmark_test() {
let loops = 100000;
let mut bd: Vec<BenchmarkData> = Vec::new();
for _i in 0..loops {
let lat = rng.gen_range(-90.0, 90.0);
let lng = rng.gen_range(-180.0, 180.0);
let mut len = rng.gen_range(2, 15);
let lat = rng.gen_range(-90.0..90.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the prevailing convention with gen_range is to pass in the interval endpoints rather than a range. Unless this is backwards-compatible and there's some recommendation to change style in new usages, mind leaving as it was?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is actually more forceful than just a style recommendation. The underlying rand crate changed the function declaration so only the new version will even compile.

let lng = rng.gen_range(-180.0..180.0);
let mut len = rng.gen_range(2..15);
// Make sure the length is even if it's less than 10.
if len < 10 && len % 2 == 1 {
len += 1;
Expand Down