Skip to content

Commit

Permalink
bump edition and get readme rendering on crates.io (pnordahl#9)
Browse files Browse the repository at this point in the history
* bump edition and get readme rendering on crates.io

* bump bindgen

* various clippy stuff
  • Loading branch information
pnordahl authored Sep 10, 2022
1 parent 8ca88a7 commit 3002625
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ jobs:
command: check
args: --verbose --all

- name: clippy
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: clippy
args: -- -D warnings

- name: build
uses: actions-rs/cargo@v1
with:
Expand Down
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ description = "FFI bindings and safe interface to libpostal"
license = "MIT"
homepage = "https://github.com/pnordahl/rust-postal"
repository = "https://github.com/pnordahl/rust-postal"
version = "0.2.4"
version = "0.2.5"
authors = ["Patrick Nordahl <[email protected]>"]
edition = "2018"
edition = "2021"
build = "build.rs"
links = "libpostal"
keywords = ["libpostal", "postal"]
readme = "README.md"
keywords = ["libpostal", "postal", "addresses"]

[dev-dependencies]
criterion = "0.2"
Expand All @@ -18,7 +19,7 @@ criterion = "0.2"
parking_lot = "0.8.0"

[build-dependencies]
bindgen = "0.54"
bindgen = "0.60"

[[bench]]
name = "benches"
Expand Down
37 changes: 28 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

extern crate parking_lot;

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[allow(clippy::too_many_arguments)]
mod bindings {
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
pub use bindings::*;

use parking_lot::Mutex;
use std::convert::TryInto;
Expand Down Expand Up @@ -41,6 +45,11 @@ impl ExpandAddressOptions {
self.c_languages_ptrs = Some(ptrs);
}
}
impl Default for ExpandAddressOptions {
fn default() -> Self {
Self::new()
}
}

pub struct Expansions<'a> {
index: isize,
Expand All @@ -53,7 +62,7 @@ impl<'a> Expansions<'a> {
pub fn new(array: *mut *mut c_char, length: usize) -> Self {
Expansions {
index: 0,
array: array,
array,
array_length: length as isize,
phantom: PhantomData,
}
Expand Down Expand Up @@ -98,7 +107,7 @@ impl<'a> Drop for Expansions<'a> {
pub struct ParseAddressOptions {
pub opts: libpostal_address_parser_options_t,
}
impl<'a> ParseAddressOptions {
impl ParseAddressOptions {
pub fn new() -> Self {
unsafe {
ParseAddressOptions {
Expand All @@ -107,6 +116,11 @@ impl<'a> ParseAddressOptions {
}
}
}
impl Default for ParseAddressOptions {
fn default() -> Self {
Self::new()
}
}

#[derive(Debug)]
pub struct Components<'a> {
Expand All @@ -119,7 +133,7 @@ impl<'a> Components<'a> {
fn new(resp: *mut libpostal_address_parser_response_t) -> Self {
Components {
index: 0,
resp: resp,
resp,
phantom: PhantomData,
}
}
Expand All @@ -144,20 +158,20 @@ impl<'a> Iterator for Components<'a> {
match ls.to_str() {
Ok(label) => {
self.index += 1;
return Some(Component {
label: label,
Some(Component {
label,
value: component,
});
})
}
Err(_) => {
// TODO: bad string from libpostal, can't really handle
return None;
None
}
}
}
Err(_) => {
// TODO: bad string from libpostal, can't really handle
return None;
None
}
}
} else {
Expand Down Expand Up @@ -268,6 +282,11 @@ impl Context {
}
}
}
impl Default for Context {
fn default() -> Self {
Self::new()
}
}
impl Drop for Context {
fn drop(&mut self) {
if self.setup_done {
Expand Down

0 comments on commit 3002625

Please sign in to comment.