1#![deny(unused_must_use)]
2#![deny(unsafe_code)]
3#![warn(rust_2018_idioms)]
4#![warn(nonstandard_style)]
5#![warn(future_incompatible)]
6#![warn(macro_use_extern_crate)]
7#![warn(explicit_outlives_requirements)]
8#![warn(missing_debug_implementations)]
9#![warn(missing_copy_implementations)]
10#![warn(unused_crate_dependencies)]
11#![warn(clippy::pedantic)]
12#![allow(dead_code)]
13#![allow(
14 clippy::semicolon_if_nothing_returned,
15 clippy::module_name_repetitions,
16 clippy::multiple_crate_versions
17)]
18
19use std::fmt;
20use std::fmt::{Display, Formatter};
21
22pub mod google;
23
24fn hijack_formatter(f: impl Fn(&mut Formatter<'_>) -> fmt::Result) -> String {
25 struct Wrapper<F>(F)
26 where
27 F: Fn(&mut Formatter<'_>) -> fmt::Result;
28 impl<F> Display for Wrapper<F>
29 where
30 F: Fn(&mut Formatter<'_>) -> fmt::Result,
31 {
32 fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
33 self.0(formatter)
34 }
35 }
36
37 format!("{}", Wrapper(f))
38}
39
40#[derive(Debug, Copy, Clone)]
41pub struct Location {
42 lat: f64,
43 lon: f64,
44}
45
46impl Location {
47 #[must_use]
48 pub fn new(lat: f64, lon: f64) -> Self {
49 Location { lat, lon }
50 }
51}
52
53impl From<(f64, f64)> for Location {
54 fn from((lat, lon): (f64, f64)) -> Self {
55 Location { lat, lon }
56 }
57}
58
59impl From<&(f64, f64)> for Location {
61 fn from((lat, lon): &(f64, f64)) -> Self {
62 Location {
63 lat: *lat,
64 lon: *lon,
65 }
66 }
67}
68
69#[derive(Debug, Copy, Clone)]
70pub struct BoundingBox {
71 p1: Location,
72 p2: Location,
73}
74
75impl BoundingBox {
76 #[must_use]
77 pub fn new(p1: Location, p2: Location) -> Self {
78 BoundingBox { p1, p2 }
79 }
80}