Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
leontoeides committed Jan 10, 2025
1 parent 7330c86 commit f9f4788
Show file tree
Hide file tree
Showing 29 changed files with 20 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize};
//
/// “The total length of the fields in this input must not exceed 280
/// characters.”
pub const MAX_CHARS: usize = 280;

// -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::LatLng;
use crate::types::LatLng;
use getset::{CopyGetters, Getters, MutGetters, Setters};
use serde::{Deserialize, Serialize};

Expand Down
4 changes: 1 addition & 3 deletions src/client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ impl crate::client::Client {
/// ## Arguments
///
/// This method accepts no arguments.
#[cfg(not(feature = "reqwest"))]
#[must_use]
pub fn build(&self) -> Self {
Expand Down Expand Up @@ -57,11 +56,10 @@ impl crate::client::Client {
/// ## Arguments
///
/// This method accepts no arguments.
#[cfg(not(feature = "reqwest"))]
#[deprecated(since = "3.4.3", note = "use `build` instead")]
#[must_use]
pub fn finalize(&self) -> Self {
self.build()
} // fn
} // impl
} // impl
2 changes: 0 additions & 2 deletions src/directions/request/location/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use rust_decimal::Decimal;
//
/// Used to specify the address, latitude/longitude, or place ID for the origin
/// and destination.
#[cfg(not(feature = "geo"))]
#[derive(
Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
Expand Down Expand Up @@ -77,7 +76,6 @@ impl std::convert::From<&Location> for String {
//
/// Used to specify the address, latitude/longitude, or place ID for the origin
/// and destination.
#[cfg(feature = "geo")]
#[derive(Clone, Debug, PartialEq)]
pub enum Location {
Expand Down
2 changes: 0 additions & 2 deletions src/directions/request/waypoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use rust_decimal::Decimal;
// -----------------------------------------------------------------------------
//
/// Used to specify pass throughs or stopovers at intermediate locations.
#[cfg(not(feature = "geo"))]
#[derive(
Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
Expand Down Expand Up @@ -79,7 +78,6 @@ impl std::convert::From<&Self> for Waypoint {
// -----------------------------------------------------------------------------
//
/// Used to specify pass throughs or stopovers at intermediate locations.
#[cfg(feature = "geo")]
#[derive(Clone, Debug, PartialEq)]
pub enum Waypoint {
Expand Down
1 change: 0 additions & 1 deletion src/directions/request/with_departure_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ impl crate::directions::Request<'_> {
/// NaiveDate::from_ymd(2030, 1, 1).and_hms(12, 30, 0)
/// ))
/// ```
#[must_use] pub fn with_departure_time(
mut self,
departure_time: impl Into<crate::directions::DepartureTime>
Expand Down
8 changes: 0 additions & 8 deletions src/directions/response/leg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ impl Leg {
/// ```rust
/// let duration_in_traffic_text = leg.get_duration_in_traffic_text();
/// ```
#[must_use]
pub fn get_duration_in_traffic_text(&self) -> Option<&String> {
self.duration_in_traffic
Expand All @@ -85,7 +84,6 @@ impl Leg {
/// ```rust
/// let duration_in_traffic_value = leg.get_duration_in_traffic_value();
/// ```
#[must_use]
pub fn get_duration_in_traffic_value(&self) -> Option<i64> {
self.duration_in_traffic
Expand All @@ -100,7 +98,6 @@ impl Leg {
/// ```rust
/// let arrival_time_text = leg.get_arrival_time_text();
/// ```
#[must_use]
pub fn get_arrival_time_text(&self) -> Option<&String> {
self.arrival_time.as_ref().map(|time| &time.text)
Expand All @@ -113,7 +110,6 @@ impl Leg {
/// ```rust
/// let arrival_time_zone = leg.arrival_time_zone();
/// ```
#[must_use]
pub fn get_arrival_time_value(&self) -> Option<i64> {
self.arrival_time
Expand All @@ -128,7 +124,6 @@ impl Leg {
/// ```rust
/// let arrival_time_zone = leg.arrival_time_zone();
/// ```
#[must_use]
pub fn get_arrival_time_zone(&self) -> Option<String> {
self.arrival_time
Expand All @@ -143,7 +138,6 @@ impl Leg {
/// ```rust
/// let departure_time_text = leg.get_departure_time_text();
/// ```
#[must_use]
pub fn get_departure_time_text(&self) -> Option<&String> {
self.departure_time.as_ref().map(|time| &time.text)
Expand All @@ -156,7 +150,6 @@ impl Leg {
/// ```rust
/// let departure_time_zone = leg.departure_time_zone();
/// ```
#[must_use]
pub fn get_departure_time_value(&self) -> Option<i64> {
self.departure_time
Expand All @@ -171,7 +164,6 @@ impl Leg {
/// ```rust
/// let departure_time_zone = leg.departure_time_zone();
/// ```
#[must_use]
pub fn get_departure_time_zone(&self) -> Option<String> {
self.departure_time
Expand Down
6 changes: 0 additions & 6 deletions src/directions/response/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl Route {
/// ```rust
/// let summary = route.get_summary();
/// ```
#[must_use]
pub fn get_summary(&self) -> Option<&String> {
match &*self.summary {
Expand All @@ -101,7 +100,6 @@ impl Route {
/// ```rust
/// let fare_currency = route.get_fare_currency();
/// ```
#[must_use]
pub fn get_fare_currency(&self) -> Option<String> {
self.fare.as_ref().map(|fare| fare.currency.to_string())
Expand All @@ -114,7 +112,6 @@ impl Route {
/// ```rust
/// let fare_value = route.get_fare_value();
/// ```
#[must_use]
pub fn get_fare_value(&self) -> Option<Decimal> {
self.fare.as_ref().map(|fare| fare.value)
Expand All @@ -127,7 +124,6 @@ impl Route {
/// ```rust
/// let fare_text = route.get_fare_text();
/// ```
#[must_use]
pub fn get_fare_text(&self) -> Option<&String> {
self.fare.as_ref().map(|fare| &fare.text)
Expand All @@ -140,7 +136,6 @@ impl Route {
/// ```rust
/// let warnings = route.get_warning();
/// ```
#[must_use]
pub fn get_warnings(&self) -> Option<String> {
if self.warnings.is_empty() {
Expand All @@ -157,7 +152,6 @@ impl Route {
/// ```rust
/// let waypoint_order = route.get_fare_text();
/// ```
#[must_use]
pub fn get_waypoint_order(&self) -> Option<String> {
if self.waypoint_order.is_empty() {
Expand Down
1 change: 0 additions & 1 deletion src/directions/response/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub enum Status {
/// See the [Maps
/// FAQ](https://developers.google.com/maps/faq#over-limit-key-error) to
/// learn how to fix this.
#[serde(alias = "OverDailyLimit")]
OverDailyLimit,

Expand Down
1 change: 0 additions & 1 deletion src/directions/response/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ impl Step {
/// ```rust
/// let maneuver = step.get_maneuver();
/// ```
pub fn get_maneuver(&self) -> Option<String> {
self.maneuver.as_ref().map(String::from)
} // fn
Expand Down
8 changes: 4 additions & 4 deletions src/elevation/request/for_positional_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ impl crate::elevation::Request<'_> {
the geo-specific methods are no longer necessary. \
it's suggested to use the `for_positional_request` method instead"
)]
#[must_use] pub fn for_coordinate_request(
self,
pub fn for_coordinate_request(
mut self,
coordinate: &geo_types::Coord
) -> Result<Self, crate::error::Error> {
// Set the path in Request struct.
Expand All @@ -105,8 +105,8 @@ impl crate::elevation::Request<'_> {
the geo-specific methods are no longer necessary. \
it's suggested to use the `for_positional_request` method instead"
)]
#[must_use] pub fn try_point_request(
self,
pub fn try_point_request(
mut self,
point: &geo_types::Point
) -> Result<Self, crate::error::Error> {
// Set the path in Request struct.
Expand Down
2 changes: 1 addition & 1 deletion src/elevation/request/for_sampled_path_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl crate::elevation::Request<'_> {
the geo-specific methods are no longer necessary. \
it's suggested to use the `for_sampled_path_request` method instead"
)]
#[must_use] pub fn for_line_string_request(
pub fn for_line_string_request(
mut self,
line_string: geo_types::LineString
) -> Result<Self, crate::error::Error> {
Expand Down
5 changes: 1 addition & 4 deletions src/elevation/request/locations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use rust_decimal_macros::dec;
//
/// Null Island: this whimsical term refers to the intersection of 0 degrees
/// latitude and 0 degrees longitude.
const NULL_ISLAND: LatLng = LatLng {
lat: dec!(0.0),
lng: dec!(0.0),
Expand All @@ -28,7 +27,6 @@ const NULL_ISLAND: LatLng = LatLng {
///
/// This parameter takes either a single location as a latitude/longitude
/// pair, multiple latitude/longitude pairs, or an encoded polyline.
#[cfg(not(feature = "geo"))]
#[derive(
Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
Expand Down Expand Up @@ -73,7 +71,6 @@ impl std::convert::From<&Locations> for String {
///
/// This parameter takes either a single location as a latitude/longitude
/// pair, multiple latitude/longitude pairs, or an encoded polyline.
#[cfg(feature = "geo")]
#[derive(Clone, Debug, PartialEq)]
pub enum Locations {
Expand Down Expand Up @@ -150,4 +147,4 @@ impl Locations {
pub fn from_polyline(polyline: impl Into<String>) -> Self {
Self::Polyline(polyline.into())
} // fn
} // impl
} // impl
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl ClassifiableError<'_, Self> for Error {
}, // Http

#[cfg(feature = "polyline")]
Self::Polyline(polyline_error) => ClassifiedError::Permanent(self),
Self::Polyline(_polyline_error) => ClassifiedError::Permanent(self),
} // match
} // fn
} // impl
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ pub use crate::types::geometry::Geometry;
pub use crate::types::language::Language;

#[cfg(any(
feature = "address_validation",
feature = "autocomplete",
feature = "directions",
feature = "distance_matrix",
Expand Down
2 changes: 1 addition & 1 deletion src/places/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pub struct Place {
pub wheelchair_accessible_entrance: Option<bool>,
} // struct Place

/// ----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

impl std::str::FromStr for Place {
type Err = simd_json::Error;
Expand Down
4 changes: 2 additions & 2 deletions src/places/place_autocomplete/response/matched_substring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct MatchedSubstring {
pub offset: usize,
} // struct MatchedSubstring

/// ----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

impl std::str::FromStr for MatchedSubstring {
type Err = simd_json::Error;
Expand All @@ -31,4 +31,4 @@ impl std::str::FromStr for MatchedSubstring {
let mut bytes = s.to_string().into_bytes();
simd_json::serde::from_slice(&mut bytes)
} // fn from_str
} // impl FromStr
} // impl FromStr
2 changes: 1 addition & 1 deletion src/places/place_autocomplete/response/prediction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub struct Prediction {
pub types: Vec<PlaceType>,
} // struct Prediction

/// ----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

impl std::str::FromStr for Prediction {
type Err = simd_json::Error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct StructuredFormat {
pub secondary_text_matched_substrings: Vec<MatchedSubstring>,
} // struct StructuredFormat

/// ----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

impl std::str::FromStr for StructuredFormat {
type Err = simd_json::Error;
Expand Down
2 changes: 1 addition & 1 deletion src/places/place_autocomplete/response/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Term {
pub value: String,
} // struct

/// ----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

impl std::str::FromStr for Term {
type Err = simd_json::Error;
Expand Down
1 change: 0 additions & 1 deletion src/places/place_opening_hours.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ impl std::str::FromStr for PlaceOpeningHours {
/// place. This is meant to be used with the `Place.current_opening_hours`
/// field. Using this with the `Place.current_opening_hours` will likely just
/// return an empty `HashSet`.
impl PlaceOpeningHours {
#[must_use]
pub fn special_days(&self) -> HashSet<NaiveDate> {
Expand Down
1 change: 0 additions & 1 deletion src/places/place_opening_hours_period.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub struct PlaceOpeningHoursPeriod {
/// `PlaceOpeningHoursPeriod` period is.
///
/// If the `close` field is empty then this method will return a `None`.
impl PlaceOpeningHoursPeriod {
#[must_use] pub fn duration(&self) -> Option<Duration> {
self.close.as_ref().map(|close| {
Expand Down
1 change: 1 addition & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub use crate::types::geometry::Geometry;
pub use crate::types::language::Language;

#[cfg(any(
feature = "address_validation",
feature = "autocomplete",
feature = "directions",
feature = "distance_matrix",
Expand Down
2 changes: 0 additions & 2 deletions src/request_rate/api_rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ impl ApiRate {
/// If the current rate exceeds the targeted rate,
/// this method will put the thread to sleep until it is ready for the next
/// request.
///
pub async fn limit(&self) {
if let Some(wait_pool) = &self.throttle_pool { wait_pool.queue().await }
/*
Expand Down
1 change: 0 additions & 1 deletion src/request_rate/duration_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::time::Duration;
/// function converts a Duration into an English expression of time. For
/// example, "1 month," "5.83 minutes," or "948 milliseconds." The unit of time
/// (i.e. milliseconds or seconds) is automatically selected by this function.
pub fn duration_to_string(duration: &Duration) -> String {
const SECONDS_IN_A_SECOND: f64 = 1.0;
const SECONDS_IN_A_MINUTE: f64 = 60.0;
Expand Down
1 change: 0 additions & 1 deletion src/request_rate/rate_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use std::time::Duration;
/// of a rate. For example, "1 file per month," "5.83 pages a minute," etc. The
/// unit of time (i.e. milliseconds or seconds) is automatically selected by
/// this function.
pub fn rate_to_string(
numerator: u64,
duration: &Duration,
Expand Down
1 change: 0 additions & 1 deletion src/request_rate/with_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ impl RequestRate {
/// with_rate(Api::Directions, 1, Duration::from_secs(3_600)) // 1 hour
/// with_rate(Api::TimeZone, 2, Duration::from_secs(60)) // 1 second
/// ```
pub fn with_rate(&mut self, api: &Api, requests: u16, duration: Duration) -> &mut Self {
// Select `RequestRate` field for the API specified by the caller.
let api_ref = self.rate_map.get_mut(api);
Expand Down
Loading

0 comments on commit f9f4788

Please sign in to comment.