Skip to content

Commit

Permalink
Disambiguated return values
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Sep 30, 2021
1 parent fa20ab6 commit 16fa18c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Sources/Turf/GeoJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public protocol GeoJSONObjectConvertible {
}

extension Geometry: GeoJSONObjectConvertible {
public var geoJSONObject: GeoJSONObject { .geometry(self) }
public var geoJSONObject: GeoJSONObject { return .geometry(self) }
}

extension Feature: GeoJSONObjectConvertible {
public var geoJSONObject: GeoJSONObject { .feature(self) }
public var geoJSONObject: GeoJSONObject { return .feature(self) }
}

extension FeatureCollection: GeoJSONObjectConvertible {
public var geoJSONObject: GeoJSONObject { .featureCollection(self) }
public var geoJSONObject: GeoJSONObject { return .featureCollection(self) }
}
16 changes: 8 additions & 8 deletions Sources/Turf/Geometry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,33 @@ public protocol GeometryConvertible {
}

extension Geometry: GeometryConvertible {
public var geometry: Geometry { self }
public var geometry: Geometry { return self }
}

extension Point: GeometryConvertible {
public var geometry: Geometry { .point(self) }
public var geometry: Geometry { return .point(self) }
}

extension LineString: GeometryConvertible {
public var geometry: Geometry { .lineString(self) }
public var geometry: Geometry { return .lineString(self) }
}

extension Polygon: GeometryConvertible {
public var geometry: Geometry { .polygon(self) }
public var geometry: Geometry { return .polygon(self) }
}

extension MultiPoint: GeometryConvertible {
public var geometry: Geometry { .multiPoint(self) }
public var geometry: Geometry { return .multiPoint(self) }
}

extension MultiLineString: GeometryConvertible {
public var geometry: Geometry { .multiLineString(self) }
public var geometry: Geometry { return .multiLineString(self) }
}

extension MultiPolygon: GeometryConvertible {
public var geometry: Geometry { .multiPolygon(self) }
public var geometry: Geometry { return .multiPolygon(self) }
}

extension GeometryCollection: GeometryConvertible {
public var geometry: Geometry { .geometryCollection(self) }
public var geometry: Geometry { return .geometryCollection(self) }
}
14 changes: 8 additions & 6 deletions Sources/Turf/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,27 +227,29 @@ public protocol JSONValueConvertible {
}

extension String: JSONValueConvertible {
public var jsonValue: JSONValue { .string(self) }
public var jsonValue: JSONValue { return .string(self) }
}

extension Int: JSONValueConvertible {
public var jsonValue: JSONValue { .number(Double(self)) }
public var jsonValue: JSONValue { return .number(Double(self)) }
}

extension Double: JSONValueConvertible {
public var jsonValue: JSONValue { .number(Double(self)) }
public var jsonValue: JSONValue { return .number(Double(self)) }
}

extension Bool: JSONValueConvertible {
public var jsonValue: JSONValue { .boolean(self) }
public var jsonValue: JSONValue { return .boolean(self) }
}

extension Array: JSONValueConvertible where Element == JSONValueConvertible? {
public var jsonValue: JSONValue { .array(map { $0?.jsonValue }) }
public var jsonValue: JSONValue {
return .array(map { $0?.jsonValue })
}
}

extension Dictionary: JSONValueConvertible where Key == String, Value == JSONValueConvertible? {
public var jsonValue: JSONValue {
.object(.init(uniqueKeysWithValues: map { ($0.0, $0.1?.jsonValue) }))
return .object(JSONObject(uniqueKeysWithValues: map { ($0.0, $0.1?.jsonValue) }))
}
}

0 comments on commit 16fa18c

Please sign in to comment.