diff --git a/.lock b/.lock new file mode 100644 index 0000000..e69de29 diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/crates.js b/crates.js new file mode 100644 index 0000000..54bb27b --- /dev/null +++ b/crates.js @@ -0,0 +1 @@ +window.ALL_CRATES = ["sfcgal_sys"]; \ No newline at end of file diff --git a/help.html b/help.html new file mode 100644 index 0000000..2d59fd4 --- /dev/null +++ b/help.html @@ -0,0 +1,2 @@ +
T
.","Some value of type T
.","Some value of type T
.","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[2,3,4,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"f":"``````{{}b}`````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````","c":[],"p":[[1,"unit"],[8,"sfcgal_error_handler_t",0],[8,"sfcgal_alloc_handler_t",0],[8,"sfcgal_free_handler_t",0]],"b":[]}]\
+]'));
+if (typeof exports !== 'undefined') exports.searchIndex = searchIndex;
+else if (window.initSearch) window.initSearch(searchIndex);
diff --git a/settings.html b/settings.html
new file mode 100644
index 0000000..42319cd
--- /dev/null
+++ b/settings.html
@@ -0,0 +1,2 @@
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_GEOMETRYCOLLECTION: sfcgal_geometry_type_t = 7;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_LINESTRING: sfcgal_geometry_type_t = 2;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTILINESTRING: sfcgal_geometry_type_t = 5;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTIPOINT: sfcgal_geometry_type_t = 4;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTIPOLYGON: sfcgal_geometry_type_t = 6;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTISOLID: sfcgal_geometry_type_t = 102;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_POINT: sfcgal_geometry_type_t = 1;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_POLYGON: sfcgal_geometry_type_t = 3;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_POLYHEDRALSURFACE: sfcgal_geometry_type_t = 15;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_SOLID: sfcgal_geometry_type_t = 101;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_TRIANGLE: sfcgal_geometry_type_t = 17;
pub const sfcgal_geometry_type_t_SFCGAL_TYPE_TRIANGULATEDSURFACE: sfcgal_geometry_type_t = 16;
pub fn initialize()
pub unsafe extern "C" fn sfcgal_approx_convex_partition_2(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_full_version() -> *const c_char
pub unsafe extern "C" fn sfcgal_geometry_alpha_shapes(
+ geom: *const sfcgal_geometry_t,
+ alpha: f64,
+ allow_holes: bool
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_approximate_medial_axis(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_area(
+ geom: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_geometry_area_3d(
+ geom: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_geometry_as_text(
+ arg1: *const sfcgal_geometry_t,
+ buffer: *mut *mut c_char,
+ len: *mut usize
+)
pub unsafe extern "C" fn sfcgal_geometry_as_text_decim(
+ arg1: *const sfcgal_geometry_t,
+ numDecimals: c_int,
+ buffer: *mut *mut c_char,
+ len: *mut usize
+)
pub unsafe extern "C" fn sfcgal_geometry_as_wkb(
+ arg1: *const sfcgal_geometry_t,
+ buffer: *mut *mut c_char,
+ len: *mut usize
+)
pub unsafe extern "C" fn sfcgal_geometry_clone(
+ arg1: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_collection_add_geometry(
+ collection: *mut sfcgal_geometry_t,
+ geometry: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_geometry_collection_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_collection_geometry_n(
+ collection: *const sfcgal_geometry_t,
+ i: usize
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_collection_num_geometries(
+ collection: *const sfcgal_geometry_t
+) -> usize
pub unsafe extern "C" fn sfcgal_geometry_convexhull(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_convexhull_3d(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_covers(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_covers_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_delete(
+ arg1: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_geometry_difference(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_difference_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_distance(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_geometry_distance_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_geometry_extrude(
+ geom: *const sfcgal_geometry_t,
+ ex: f64,
+ ey: f64,
+ ez: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_extrude_polygon_straight_skeleton(
+ geom: *const sfcgal_geometry_t,
+ building_height: f64,
+ roof_height: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_extrude_straight_skeleton(
+ geom: *const sfcgal_geometry_t,
+ height: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_force_lhr(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_force_rhr(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_force_valid(
+ geom: *mut sfcgal_geometry_t,
+ valid: c_int
+)
pub unsafe extern "C" fn sfcgal_geometry_has_validity_flag(
+ geom: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_intersection(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_intersection_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_intersects(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_intersects_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_is_3d(
+ arg1: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_is_empty(
+ arg1: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_is_measured(
+ arg1: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_is_planar(
+ geom: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_is_valid(
+ arg1: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_is_valid_detail(
+ geom: *const sfcgal_geometry_t,
+ invalidity_reason: *mut *mut c_char,
+ invalidity_location: *mut *mut sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_line_sub_string(
+ geom: *const sfcgal_geometry_t,
+ start: f64,
+ end: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_make_solid(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_minkowski_sum(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_offset_polygon(
+ geom: *const sfcgal_geometry_t,
+ radius: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_optimal_alpha_shapes(
+ geom: *const sfcgal_geometry_t,
+ allow_holes: bool,
+ nb_components: usize
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_orientation(
+ geom: *const sfcgal_geometry_t
+) -> c_int
pub unsafe extern "C" fn sfcgal_geometry_round(
+ geom: *const sfcgal_geometry_t,
+ r: c_int
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_straight_skeleton(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_straight_skeleton_distance_in_m(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_tesselate(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_triangulate_2dz(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_type_id(
+ arg1: *const sfcgal_geometry_t
+) -> sfcgal_geometry_type_t
pub unsafe extern "C" fn sfcgal_geometry_union(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_union_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_visibility_point(
+ polygon: *const sfcgal_geometry_t,
+ point: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_visibility_segment(
+ polygon: *const sfcgal_geometry_t,
+ pointA: *const sfcgal_geometry_t,
+ pointB: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_geometry_volume(
+ geom: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_greene_approx_convex_partition_2(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_init()
pub unsafe extern "C" fn sfcgal_io_read_binary_prepared(
+ arg1: *const c_char,
+ l: usize
+) -> *mut sfcgal_prepared_geometry_t
pub unsafe extern "C" fn sfcgal_io_read_ewkt(
+ arg1: *const c_char,
+ len: usize
+) -> *mut sfcgal_prepared_geometry_t
pub unsafe extern "C" fn sfcgal_io_read_wkb(
+ arg1: *const c_char,
+ len: usize
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_io_read_wkt(
+ arg1: *const c_char,
+ len: usize
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_io_write_binary_prepared(
+ arg1: *const sfcgal_prepared_geometry_t,
+ arg2: *mut *mut c_char,
+ arg3: *mut usize
+)
pub unsafe extern "C" fn sfcgal_linestring_add_point(
+ linestring: *mut sfcgal_geometry_t,
+ point: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_linestring_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_linestring_num_points(
+ linestring: *const sfcgal_geometry_t
+) -> usize
pub unsafe extern "C" fn sfcgal_linestring_point_n(
+ linestring: *const sfcgal_geometry_t,
+ i: usize
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_multi_linestring_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_multi_point_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_multi_polygon_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_optimal_convex_partition_2(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_point_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_point_create_from_xy(
+ x: f64,
+ y: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_point_create_from_xym(
+ x: f64,
+ y: f64,
+ m: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_point_create_from_xyz(
+ x: f64,
+ y: f64,
+ z: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_point_create_from_xyzm(
+ x: f64,
+ y: f64,
+ z: f64,
+ m: f64
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_point_m(
+ arg1: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_point_x(
+ arg1: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_point_y(
+ arg1: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_point_z(
+ arg1: *const sfcgal_geometry_t
+) -> f64
pub unsafe extern "C" fn sfcgal_polygon_add_interior_ring(
+ polygon: *mut sfcgal_geometry_t,
+ ring: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_polygon_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_polygon_create_from_exterior_ring(
+ ring: *mut sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_polygon_exterior_ring(
+ polygon: *const sfcgal_geometry_t
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_polygon_interior_ring_n(
+ polygon: *const sfcgal_geometry_t,
+ i: usize
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_polygon_num_interior_rings(
+ polygon: *const sfcgal_geometry_t
+) -> usize
pub unsafe extern "C" fn sfcgal_polyhedral_surface_add_polygon(
+ polyhedral: *mut sfcgal_geometry_t,
+ polygon: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_polyhedral_surface_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_polyhedral_surface_num_polygons(
+ polyhedral: *const sfcgal_geometry_t
+) -> usize
pub unsafe extern "C" fn sfcgal_polyhedral_surface_polygon_n(
+ polyhedral: *const sfcgal_geometry_t,
+ i: usize
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_prepared_geometry_as_ewkt(
+ prepared: *const sfcgal_prepared_geometry_t,
+ num_decimals: c_int,
+ buffer: *mut *mut c_char,
+ len: *mut usize
+)
pub unsafe extern "C" fn sfcgal_prepared_geometry_create(
+) -> *mut sfcgal_prepared_geometry_t
pub unsafe extern "C" fn sfcgal_prepared_geometry_create_from_geometry(
+ geometry: *mut sfcgal_geometry_t,
+ srid: srid_t
+) -> *mut sfcgal_prepared_geometry_t
pub unsafe extern "C" fn sfcgal_prepared_geometry_delete(
+ prepared: *mut sfcgal_prepared_geometry_t
+)
pub unsafe extern "C" fn sfcgal_prepared_geometry_geometry(
+ prepared: *const sfcgal_prepared_geometry_t
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_prepared_geometry_set_geometry(
+ prepared: *mut sfcgal_prepared_geometry_t,
+ geometry: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_prepared_geometry_set_srid(
+ prepared: *mut sfcgal_prepared_geometry_t,
+ arg1: srid_t
+)
pub unsafe extern "C" fn sfcgal_prepared_geometry_srid(
+ prepared: *const sfcgal_prepared_geometry_t
+) -> srid_t
pub unsafe extern "C" fn sfcgal_set_alloc_handlers(
+ malloc_handler: sfcgal_alloc_handler_t,
+ free_handler: sfcgal_free_handler_t
+)
pub unsafe extern "C" fn sfcgal_set_error_handlers(
+ warning_handler: sfcgal_error_handler_t,
+ error_handler: sfcgal_error_handler_t
+)
pub unsafe extern "C" fn sfcgal_set_geometry_validation(
+ enabled: c_int
+)
pub unsafe extern "C" fn sfcgal_solid_add_interior_shell(
+ solid: *mut sfcgal_geometry_t,
+ shell: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_solid_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_solid_create_from_exterior_shell(
+ shell: *mut sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_solid_num_shells(
+ solid: *const sfcgal_geometry_t
+) -> usize
pub unsafe extern "C" fn sfcgal_solid_shell_n(
+ solid: *const sfcgal_geometry_t,
+ i: usize
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_triangle_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_triangle_create_from_points(
+ pta: *const sfcgal_geometry_t,
+ ptb: *const sfcgal_geometry_t,
+ ptc: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_triangle_set_vertex(
+ triangle: *mut sfcgal_geometry_t,
+ i: c_int,
+ vertex: *const sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_triangle_set_vertex_from_xy(
+ triangle: *mut sfcgal_geometry_t,
+ i: c_int,
+ x: f64,
+ y: f64
+)
pub unsafe extern "C" fn sfcgal_triangle_set_vertex_from_xyz(
+ triangle: *mut sfcgal_geometry_t,
+ i: c_int,
+ x: f64,
+ y: f64,
+ z: f64
+)
pub unsafe extern "C" fn sfcgal_triangle_vertex(
+ triangle: *const sfcgal_geometry_t,
+ i: c_int
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_triangulated_surface_add_triangle(
+ tin: *mut sfcgal_geometry_t,
+ triangle: *mut sfcgal_geometry_t
+)
pub unsafe extern "C" fn sfcgal_triangulated_surface_create(
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_triangulated_surface_num_triangles(
+ tin: *const sfcgal_geometry_t
+) -> usize
pub unsafe extern "C" fn sfcgal_triangulated_surface_triangle_n(
+ tin: *const sfcgal_geometry_t,
+ i: usize
+) -> *const sfcgal_geometry_t
pub unsafe extern "C" fn sfcgal_version() -> *const c_char
pub unsafe extern "C" fn sfcgal_y_monotone_partition_2(
+ geom: *const sfcgal_geometry_t
+) -> *mut sfcgal_geometry_t
pub unsafe extern "C" fn w_sfcgal_get_last_error() -> *mut c_char
pub unsafe extern "C" fn w_sfcgal_get_last_warning() -> *mut c_char
pub unsafe extern "C" fn w_sfcgal_init_handlers() -> c_int
pub type sfcgal_geometry_t = c_void;
enum sfcgal_geometry_t {
+ // some variants omitted
+}
pub type sfcgal_geometry_type_t = c_uint;
pub type sfcgal_prepared_geometry_t = c_void;
enum sfcgal_prepared_geometry_t {
+ // some variants omitted
+}
pub type srid_t = u32;
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +
/* automatically generated by rust-bindgen 0.69.4 */
+
+pub type sfcgal_geometry_t = ::std::os::raw::c_void;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_POINT: sfcgal_geometry_type_t = 1;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_LINESTRING: sfcgal_geometry_type_t = 2;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_POLYGON: sfcgal_geometry_type_t = 3;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTIPOINT: sfcgal_geometry_type_t = 4;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTILINESTRING: sfcgal_geometry_type_t = 5;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTIPOLYGON: sfcgal_geometry_type_t = 6;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_GEOMETRYCOLLECTION: sfcgal_geometry_type_t = 7;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_POLYHEDRALSURFACE: sfcgal_geometry_type_t = 15;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_TRIANGULATEDSURFACE: sfcgal_geometry_type_t = 16;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_TRIANGLE: sfcgal_geometry_type_t = 17;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_SOLID: sfcgal_geometry_type_t = 101;
+pub const sfcgal_geometry_type_t_SFCGAL_TYPE_MULTISOLID: sfcgal_geometry_type_t = 102;
+pub type sfcgal_geometry_type_t = ::std::os::raw::c_uint;
+extern "C" {
+ pub fn sfcgal_set_geometry_validation(enabled: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn sfcgal_geometry_type_id(arg1: *const sfcgal_geometry_t) -> sfcgal_geometry_type_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_is_valid(arg1: *const sfcgal_geometry_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_is_valid_detail(
+ geom: *const sfcgal_geometry_t,
+ invalidity_reason: *mut *mut ::std::os::raw::c_char,
+ invalidity_location: *mut *mut sfcgal_geometry_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_is_3d(arg1: *const sfcgal_geometry_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_is_measured(arg1: *const sfcgal_geometry_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_is_empty(arg1: *const sfcgal_geometry_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_clone(arg1: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_delete(arg1: *mut sfcgal_geometry_t);
+}
+extern "C" {
+ pub fn sfcgal_geometry_as_text(
+ arg1: *const sfcgal_geometry_t,
+ buffer: *mut *mut ::std::os::raw::c_char,
+ len: *mut usize,
+ );
+}
+extern "C" {
+ pub fn sfcgal_geometry_as_text_decim(
+ arg1: *const sfcgal_geometry_t,
+ numDecimals: ::std::os::raw::c_int,
+ buffer: *mut *mut ::std::os::raw::c_char,
+ len: *mut usize,
+ );
+}
+extern "C" {
+ pub fn sfcgal_geometry_as_wkb(
+ arg1: *const sfcgal_geometry_t,
+ buffer: *mut *mut ::std::os::raw::c_char,
+ len: *mut usize,
+ );
+}
+extern "C" {
+ pub fn sfcgal_point_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_point_create_from_xy(x: f64, y: f64) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_point_create_from_xyz(x: f64, y: f64, z: f64) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_point_create_from_xym(x: f64, y: f64, m: f64) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_point_create_from_xyzm(x: f64, y: f64, z: f64, m: f64) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_point_x(arg1: *const sfcgal_geometry_t) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_point_y(arg1: *const sfcgal_geometry_t) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_point_z(arg1: *const sfcgal_geometry_t) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_point_m(arg1: *const sfcgal_geometry_t) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_linestring_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_linestring_num_points(linestring: *const sfcgal_geometry_t) -> usize;
+}
+extern "C" {
+ pub fn sfcgal_linestring_point_n(
+ linestring: *const sfcgal_geometry_t,
+ i: usize,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_linestring_add_point(
+ linestring: *mut sfcgal_geometry_t,
+ point: *mut sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_triangle_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_triangle_create_from_points(
+ pta: *const sfcgal_geometry_t,
+ ptb: *const sfcgal_geometry_t,
+ ptc: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_triangle_vertex(
+ triangle: *const sfcgal_geometry_t,
+ i: ::std::os::raw::c_int,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_triangle_set_vertex(
+ triangle: *mut sfcgal_geometry_t,
+ i: ::std::os::raw::c_int,
+ vertex: *const sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_triangle_set_vertex_from_xy(
+ triangle: *mut sfcgal_geometry_t,
+ i: ::std::os::raw::c_int,
+ x: f64,
+ y: f64,
+ );
+}
+extern "C" {
+ pub fn sfcgal_triangle_set_vertex_from_xyz(
+ triangle: *mut sfcgal_geometry_t,
+ i: ::std::os::raw::c_int,
+ x: f64,
+ y: f64,
+ z: f64,
+ );
+}
+extern "C" {
+ pub fn sfcgal_polygon_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_polygon_create_from_exterior_ring(
+ ring: *mut sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_polygon_exterior_ring(
+ polygon: *const sfcgal_geometry_t,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_polygon_num_interior_rings(polygon: *const sfcgal_geometry_t) -> usize;
+}
+extern "C" {
+ pub fn sfcgal_polygon_interior_ring_n(
+ polygon: *const sfcgal_geometry_t,
+ i: usize,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_polygon_add_interior_ring(
+ polygon: *mut sfcgal_geometry_t,
+ ring: *mut sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_geometry_collection_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_collection_num_geometries(collection: *const sfcgal_geometry_t)
+ -> usize;
+}
+extern "C" {
+ pub fn sfcgal_geometry_collection_geometry_n(
+ collection: *const sfcgal_geometry_t,
+ i: usize,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_collection_add_geometry(
+ collection: *mut sfcgal_geometry_t,
+ geometry: *mut sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_multi_point_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_multi_linestring_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_multi_polygon_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_polyhedral_surface_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_polyhedral_surface_num_polygons(polyhedral: *const sfcgal_geometry_t) -> usize;
+}
+extern "C" {
+ pub fn sfcgal_polyhedral_surface_polygon_n(
+ polyhedral: *const sfcgal_geometry_t,
+ i: usize,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_polyhedral_surface_add_polygon(
+ polyhedral: *mut sfcgal_geometry_t,
+ polygon: *mut sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_triangulated_surface_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_triangulated_surface_num_triangles(tin: *const sfcgal_geometry_t) -> usize;
+}
+extern "C" {
+ pub fn sfcgal_triangulated_surface_triangle_n(
+ tin: *const sfcgal_geometry_t,
+ i: usize,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_triangulated_surface_add_triangle(
+ tin: *mut sfcgal_geometry_t,
+ triangle: *mut sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_solid_create() -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_solid_create_from_exterior_shell(
+ shell: *mut sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_solid_num_shells(solid: *const sfcgal_geometry_t) -> usize;
+}
+extern "C" {
+ pub fn sfcgal_solid_shell_n(
+ solid: *const sfcgal_geometry_t,
+ i: usize,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_solid_add_interior_shell(
+ solid: *mut sfcgal_geometry_t,
+ shell: *mut sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_geometry_has_validity_flag(
+ geom: *const sfcgal_geometry_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_force_valid(geom: *mut sfcgal_geometry_t, valid: ::std::os::raw::c_int);
+}
+pub type sfcgal_prepared_geometry_t = ::std::os::raw::c_void;
+pub type srid_t = u32;
+extern "C" {
+ pub fn sfcgal_prepared_geometry_create() -> *mut sfcgal_prepared_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_prepared_geometry_create_from_geometry(
+ geometry: *mut sfcgal_geometry_t,
+ srid: srid_t,
+ ) -> *mut sfcgal_prepared_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_prepared_geometry_delete(prepared: *mut sfcgal_prepared_geometry_t);
+}
+extern "C" {
+ pub fn sfcgal_prepared_geometry_geometry(
+ prepared: *const sfcgal_prepared_geometry_t,
+ ) -> *const sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_prepared_geometry_set_geometry(
+ prepared: *mut sfcgal_prepared_geometry_t,
+ geometry: *mut sfcgal_geometry_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_prepared_geometry_srid(prepared: *const sfcgal_prepared_geometry_t) -> srid_t;
+}
+extern "C" {
+ pub fn sfcgal_prepared_geometry_set_srid(
+ prepared: *mut sfcgal_prepared_geometry_t,
+ arg1: srid_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_prepared_geometry_as_ewkt(
+ prepared: *const sfcgal_prepared_geometry_t,
+ num_decimals: ::std::os::raw::c_int,
+ buffer: *mut *mut ::std::os::raw::c_char,
+ len: *mut usize,
+ );
+}
+extern "C" {
+ pub fn sfcgal_io_read_wkt(
+ arg1: *const ::std::os::raw::c_char,
+ len: usize,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_io_read_ewkt(
+ arg1: *const ::std::os::raw::c_char,
+ len: usize,
+ ) -> *mut sfcgal_prepared_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_io_read_wkb(
+ arg1: *const ::std::os::raw::c_char,
+ len: usize,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_io_write_binary_prepared(
+ arg1: *const sfcgal_prepared_geometry_t,
+ arg2: *mut *mut ::std::os::raw::c_char,
+ arg3: *mut usize,
+ );
+}
+extern "C" {
+ pub fn sfcgal_io_read_binary_prepared(
+ arg1: *const ::std::os::raw::c_char,
+ l: usize,
+ ) -> *mut sfcgal_prepared_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_intersects(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_intersects_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_intersection(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_intersection_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_difference(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_difference_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_union(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_union_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_convexhull(geom: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_convexhull_3d(geom: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_volume(geom: *const sfcgal_geometry_t) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_geometry_area(geom: *const sfcgal_geometry_t) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_geometry_area_3d(geom: *const sfcgal_geometry_t) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_geometry_is_planar(geom: *const sfcgal_geometry_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_orientation(geom: *const sfcgal_geometry_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_tesselate(geom: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_triangulate_2dz(
+ geom: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_extrude(
+ geom: *const sfcgal_geometry_t,
+ ex: f64,
+ ey: f64,
+ ez: f64,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_make_solid(geom: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_force_lhr(geom: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_force_rhr(geom: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_distance(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_geometry_distance_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> f64;
+}
+extern "C" {
+ pub fn sfcgal_geometry_round(
+ geom: *const sfcgal_geometry_t,
+ r: ::std::os::raw::c_int,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_minkowski_sum(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_offset_polygon(
+ geom: *const sfcgal_geometry_t,
+ radius: f64,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_straight_skeleton(
+ geom: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_straight_skeleton_distance_in_m(
+ geom: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_extrude_straight_skeleton(
+ geom: *const sfcgal_geometry_t,
+ height: f64,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_extrude_polygon_straight_skeleton(
+ geom: *const sfcgal_geometry_t,
+ building_height: f64,
+ roof_height: f64,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_approximate_medial_axis(
+ geom: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_covers(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_covers_3d(
+ geom1: *const sfcgal_geometry_t,
+ geom2: *const sfcgal_geometry_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sfcgal_geometry_line_sub_string(
+ geom: *const sfcgal_geometry_t,
+ start: f64,
+ end: f64,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_alpha_shapes(
+ geom: *const sfcgal_geometry_t,
+ alpha: f64,
+ allow_holes: bool,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_optimal_alpha_shapes(
+ geom: *const sfcgal_geometry_t,
+ allow_holes: bool,
+ nb_components: usize,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_y_monotone_partition_2(geom: *const sfcgal_geometry_t) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_approx_convex_partition_2(
+ geom: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_greene_approx_convex_partition_2(
+ geom: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_optimal_convex_partition_2(
+ geom: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_visibility_point(
+ polygon: *const sfcgal_geometry_t,
+ point: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+extern "C" {
+ pub fn sfcgal_geometry_visibility_segment(
+ polygon: *const sfcgal_geometry_t,
+ pointA: *const sfcgal_geometry_t,
+ pointB: *const sfcgal_geometry_t,
+ ) -> *mut sfcgal_geometry_t;
+}
+pub type sfcgal_error_handler_t = ::std::option::Option<
+ unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int,
+>;
+extern "C" {
+ pub fn sfcgal_set_error_handlers(
+ warning_handler: sfcgal_error_handler_t,
+ error_handler: sfcgal_error_handler_t,
+ );
+}
+pub type sfcgal_alloc_handler_t =
+ ::std::option::Option<unsafe extern "C" fn(arg1: usize) -> *mut ::std::os::raw::c_void>;
+pub type sfcgal_free_handler_t =
+ ::std::option::Option<unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void)>;
+extern "C" {
+ pub fn sfcgal_set_alloc_handlers(
+ malloc_handler: sfcgal_alloc_handler_t,
+ free_handler: sfcgal_free_handler_t,
+ );
+}
+extern "C" {
+ pub fn sfcgal_init();
+}
+extern "C" {
+ pub fn sfcgal_version() -> *const ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn sfcgal_full_version() -> *const ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn w_sfcgal_init_handlers() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn w_sfcgal_get_last_error() -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn w_sfcgal_get_last_warning() -> *mut ::std::os::raw::c_char;
+}
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +
#![allow(non_upper_case_globals)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+
+use std::sync::Once;
+
+include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
+
+pub fn initialize() {
+ static INIT: Once = Once::new();
+ INIT.call_once(|| unsafe {
+ sfcgal_init();
+ w_sfcgal_init_handlers();
+ });
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::*;
+ use std::ffi::{CStr, CString};
+
+ fn _string(raw_ptr: *const std::os::raw::c_char) -> String {
+ let c_str = unsafe { CStr::from_ptr(raw_ptr) };
+ std::str::from_utf8(c_str.to_bytes()).unwrap().to_string()
+ }
+
+ #[test]
+ fn it_works() {
+ initialize();
+ let wkt1 = CString::new("POINT(1.0 1.0)").expect("CString::new failed");
+ let point1 = unsafe { sfcgal_io_read_wkt(wkt1.as_ptr(), 14) };
+ let wkt2 = CString::new("POINT(10.0 1.0)").expect("CString::new failed");
+ let point2 = unsafe { sfcgal_io_read_wkt(wkt2.as_ptr(), 15) };
+ let distance = unsafe { sfcgal_geometry_distance(point1, point2) };
+ assert_eq!(distance, 9.0);
+ }
+
+ #[test]
+ fn it_handles_errors() {
+ initialize();
+ let wkt1 = CString::new("POINT(1, 1)").expect("CString::new failed");
+ let _point1 = unsafe { sfcgal_io_read_wkt(wkt1.as_ptr(), 10) };
+ let message = unsafe { w_sfcgal_get_last_error() };
+ assert_eq!(
+ _string(message),
+ String::from("WKT parse error, Coordinate dimension < 2 (, 1)"),
+ );
+ }
+}
+
fn:
) to \
+ restrict the search to a given item kind.","Accepted kinds are: fn
, mod
, struct
, \
+ enum
, trait
, type
, macro
, \
+ and const
.","Search functions by type signature (e.g., vec -> usize
or \
+ -> vec
or String, enum:Cow -> bool
)","You can look for items with an exact name by putting double quotes around \
+ your request: \"string\"
","Look for functions that accept or return \
+ slices and \
+ arrays by writing \
+ square brackets (e.g., -> [u8]
or [] -> Option
)","Look for items inside another one by searching for a path: vec::Vec
",].map(x=>""+x+"
").join("");const div_infos=document.createElement("div");addClass(div_infos,"infos");div_infos.innerHTML="${value.replaceAll(" ", " ")}
`}else{error[index]=value}});output+=`Returns true
if the option is a Some
and the value inside of it matches a predicate.
let x: Option<u32> = Some(2);\nassert_eq!(x.is_some_and(|x| x > 1), true);\n\nlet x: Option<u32> = Some(0);\nassert_eq!(x.is_some_and(|x| x > 1), false);\n\nlet x: Option<u32> = None;\nassert_eq!(x.is_some_and(|x| x > 1), false);
Converts from &Option<T>
to Option<&T>
.
Calculates the length of an Option<String>
as an Option<usize>
\nwithout moving the String
. The map
method takes the self
argument by value,\nconsuming the original, so this technique uses as_ref
to first take an Option
to a\nreference to the value inside the original.
let text: Option<String> = Some(\"Hello, world!\".to_string());\n// First, cast `Option<String>` to `Option<&String>` with `as_ref`,\n// then consume *that* with `map`, leaving `text` on the stack.\nlet text_length: Option<usize> = text.as_ref().map(|s| s.len());\nprintln!(\"still can print text: {text:?}\");
Converts from &mut Option<T>
to Option<&mut T>
.
let mut x = Some(2);\nmatch x.as_mut() {\n Some(v) => *v = 42,\n None => {},\n}\nassert_eq!(x, Some(42));
Returns a slice of the contained value, if any. If this is None
, an\nempty slice is returned. This can be useful to have a single type of\niterator over an Option
or slice.
Note: Should you have an Option<&T>
and wish to get a slice of T
,\nyou can unpack it via opt.map_or(&[], std::slice::from_ref)
.
assert_eq!(\n [Some(1234).as_slice(), None.as_slice()],\n [&[1234][..], &[][..]],\n);
The inverse of this function is (discounting\nborrowing) [_]::first
:
for i in [Some(1234_u16), None] {\n assert_eq!(i.as_ref(), i.as_slice().first());\n}
Returns a mutable slice of the contained value, if any. If this is\nNone
, an empty slice is returned. This can be useful to have a\nsingle type of iterator over an Option
or slice.
Note: Should you have an Option<&mut T>
instead of a\n&mut Option<T>
, which this method takes, you can obtain a mutable\nslice via opt.map_or(&mut [], std::slice::from_mut)
.
assert_eq!(\n [Some(1234).as_mut_slice(), None.as_mut_slice()],\n [&mut [1234][..], &mut [][..]],\n);
The result is a mutable slice of zero or one items that points into\nour original Option
:
let mut x = Some(1234);\nx.as_mut_slice()[0] += 1;\nassert_eq!(x, Some(1235));
The inverse of this method (discounting borrowing)\nis [_]::first_mut
:
assert_eq!(Some(123).as_mut_slice().first_mut(), Some(&mut 123))
Returns the contained Some
value, consuming the self
value.
Panics if the value is a None
with a custom panic message provided by\nmsg
.
let x = Some(\"value\");\nassert_eq!(x.expect(\"fruits are healthy\"), \"value\");
let x: Option<&str> = None;\nx.expect(\"fruits are healthy\"); // panics with `fruits are healthy`
We recommend that expect
messages are used to describe the reason you\nexpect the Option
should be Some
.
let item = slice.get(0)\n .expect(\"slice should not be empty\");
Hint: If you’re having trouble remembering how to phrase expect\nerror messages remember to focus on the word “should” as in “env\nvariable should be set by blah” or “the given binary should be available\nand executable by the current user”.
\nFor more detail on expect message styles and the reasoning behind our\nrecommendation please refer to the section on “Common Message\nStyles” in the std::error
module docs.
Returns the contained Some
value, consuming the self
value.
Because this function may panic, its use is generally discouraged.\nInstead, prefer to use pattern matching and handle the None
\ncase explicitly, or call unwrap_or
, unwrap_or_else
, or\nunwrap_or_default
.
Panics if the self value equals None
.
let x = Some(\"air\");\nassert_eq!(x.unwrap(), \"air\");
let x: Option<&str> = None;\nassert_eq!(x.unwrap(), \"air\"); // fails
Returns the contained Some
value or a provided default.
Arguments passed to unwrap_or
are eagerly evaluated; if you are passing\nthe result of a function call, it is recommended to use unwrap_or_else
,\nwhich is lazily evaluated.
assert_eq!(Some(\"car\").unwrap_or(\"bike\"), \"car\");\nassert_eq!(None.unwrap_or(\"bike\"), \"bike\");
Returns the contained Some
value or a default.
Consumes the self
argument then, if Some
, returns the contained\nvalue, otherwise if None
, returns the default value for that\ntype.
let x: Option<u32> = None;\nlet y: Option<u32> = Some(12);\n\nassert_eq!(x.unwrap_or_default(), 0);\nassert_eq!(y.unwrap_or_default(), 12);
Returns the contained Some
value, consuming the self
value,\nwithout checking that the value is not None
.
Calling this method on None
is undefined behavior.
let x = Some(\"air\");\nassert_eq!(unsafe { x.unwrap_unchecked() }, \"air\");
let x: Option<&str> = None;\nassert_eq!(unsafe { x.unwrap_unchecked() }, \"air\"); // Undefined behavior!
Maps an Option<T>
to Option<U>
by applying a function to a contained value (if Some
) or returns None
(if None
).
Calculates the length of an Option<String>
as an\nOption<usize>
, consuming the original:
let maybe_some_string = Some(String::from(\"Hello, World!\"));\n// `Option::map` takes self *by value*, consuming `maybe_some_string`\nlet maybe_some_len = maybe_some_string.map(|s| s.len());\nassert_eq!(maybe_some_len, Some(13));\n\nlet x: Option<&str> = None;\nassert_eq!(x.map(|s| s.len()), None);
Calls the provided closure with a reference to the contained value (if Some
).
let v = vec![1, 2, 3, 4, 5];\n\n// prints \"got: 4\"\nlet x: Option<&usize> = v.get(3).inspect(|x| println!(\"got: {x}\"));\n\n// prints nothing\nlet x: Option<&usize> = v.get(5).inspect(|x| println!(\"got: {x}\"));
Returns the provided default result (if none),\nor applies a function to the contained value (if any).
\nArguments passed to map_or
are eagerly evaluated; if you are passing\nthe result of a function call, it is recommended to use map_or_else
,\nwhich is lazily evaluated.
let x = Some(\"foo\");\nassert_eq!(x.map_or(42, |v| v.len()), 3);\n\nlet x: Option<&str> = None;\nassert_eq!(x.map_or(42, |v| v.len()), 42);
Computes a default function result (if none), or\napplies a different function to the contained value (if any).
\nlet k = 21;\n\nlet x = Some(\"foo\");\nassert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3);\n\nlet x: Option<&str> = None;\nassert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42);
A somewhat common occurrence when dealing with optional values\nin combination with Result<T, E>
is the case where one wants to invoke\na fallible fallback if the option is not present. This example\nparses a command line argument (if present), or the contents of a file to\nan integer. However, unlike accessing the command line argument, reading\nthe file is fallible, so it must be wrapped with Ok
.
let v: u64 = std::env::args()\n .nth(1)\n .map_or_else(|| std::fs::read_to_string(\"/etc/someconfig.conf\"), Ok)?\n .parse()?;
Transforms the Option<T>
into a Result<T, E>
, mapping Some(v)
to\nOk(v)
and None
to Err(err)
.
Arguments passed to ok_or
are eagerly evaluated; if you are passing the\nresult of a function call, it is recommended to use ok_or_else
, which is\nlazily evaluated.
let x = Some(\"foo\");\nassert_eq!(x.ok_or(0), Ok(\"foo\"));\n\nlet x: Option<&str> = None;\nassert_eq!(x.ok_or(0), Err(0));
Transforms the Option<T>
into a Result<T, E>
, mapping Some(v)
to\nOk(v)
and None
to Err(err())
.
let x = Some(\"foo\");\nassert_eq!(x.ok_or_else(|| 0), Ok(\"foo\"));\n\nlet x: Option<&str> = None;\nassert_eq!(x.ok_or_else(|| 0), Err(0));
Converts from Option<T>
(or &Option<T>
) to Option<&T::Target>
.
Leaves the original Option in-place, creating a new one with a reference\nto the original one, additionally coercing the contents via Deref
.
let x: Option<String> = Some(\"hey\".to_owned());\nassert_eq!(x.as_deref(), Some(\"hey\"));\n\nlet x: Option<String> = None;\nassert_eq!(x.as_deref(), None);
Converts from Option<T>
(or &mut Option<T>
) to Option<&mut T::Target>
.
Leaves the original Option
in-place, creating a new one containing a mutable reference to\nthe inner type’s Deref::Target
type.
let mut x: Option<String> = Some(\"hey\".to_owned());\nassert_eq!(x.as_deref_mut().map(|x| {\n x.make_ascii_uppercase();\n x\n}), Some(\"HEY\".to_owned().as_mut_str()));
Returns an iterator over the possibly contained value.
\nlet x = Some(4);\nassert_eq!(x.iter().next(), Some(&4));\n\nlet x: Option<u32> = None;\nassert_eq!(x.iter().next(), None);
Returns a mutable iterator over the possibly contained value.
\nlet mut x = Some(4);\nmatch x.iter_mut().next() {\n Some(v) => *v = 42,\n None => {},\n}\nassert_eq!(x, Some(42));\n\nlet mut x: Option<u32> = None;\nassert_eq!(x.iter_mut().next(), None);
Returns None
if the option is None
, otherwise returns optb
.
Arguments passed to and
are eagerly evaluated; if you are passing the\nresult of a function call, it is recommended to use and_then
, which is\nlazily evaluated.
let x = Some(2);\nlet y: Option<&str> = None;\nassert_eq!(x.and(y), None);\n\nlet x: Option<u32> = None;\nlet y = Some(\"foo\");\nassert_eq!(x.and(y), None);\n\nlet x = Some(2);\nlet y = Some(\"foo\");\nassert_eq!(x.and(y), Some(\"foo\"));\n\nlet x: Option<u32> = None;\nlet y: Option<&str> = None;\nassert_eq!(x.and(y), None);
Returns None
if the option is None
, otherwise calls f
with the\nwrapped value and returns the result.
Some languages call this operation flatmap.
\nfn sq_then_to_string(x: u32) -> Option<String> {\n x.checked_mul(x).map(|sq| sq.to_string())\n}\n\nassert_eq!(Some(2).and_then(sq_then_to_string), Some(4.to_string()));\nassert_eq!(Some(1_000_000).and_then(sq_then_to_string), None); // overflowed!\nassert_eq!(None.and_then(sq_then_to_string), None);
Often used to chain fallible operations that may return None
.
let arr_2d = [[\"A0\", \"A1\"], [\"B0\", \"B1\"]];\n\nlet item_0_1 = arr_2d.get(0).and_then(|row| row.get(1));\nassert_eq!(item_0_1, Some(&\"A1\"));\n\nlet item_2_0 = arr_2d.get(2).and_then(|row| row.get(0));\nassert_eq!(item_2_0, None);
Returns None
if the option is None
, otherwise calls predicate
\nwith the wrapped value and returns:
Some(t)
if predicate
returns true
(where t
is the wrapped\nvalue), andNone
if predicate
returns false
.This function works similar to Iterator::filter()
. You can imagine\nthe Option<T>
being an iterator over one or zero elements. filter()
\nlets you decide which elements to keep.
fn is_even(n: &i32) -> bool {\n n % 2 == 0\n}\n\nassert_eq!(None.filter(is_even), None);\nassert_eq!(Some(3).filter(is_even), None);\nassert_eq!(Some(4).filter(is_even), Some(4));
Returns the option if it contains a value, otherwise returns optb
.
Arguments passed to or
are eagerly evaluated; if you are passing the\nresult of a function call, it is recommended to use or_else
, which is\nlazily evaluated.
let x = Some(2);\nlet y = None;\nassert_eq!(x.or(y), Some(2));\n\nlet x = None;\nlet y = Some(100);\nassert_eq!(x.or(y), Some(100));\n\nlet x = Some(2);\nlet y = Some(100);\nassert_eq!(x.or(y), Some(2));\n\nlet x: Option<u32> = None;\nlet y = None;\nassert_eq!(x.or(y), None);
Returns the option if it contains a value, otherwise calls f
and\nreturns the result.
fn nobody() -> Option<&'static str> { None }\nfn vikings() -> Option<&'static str> { Some(\"vikings\") }\n\nassert_eq!(Some(\"barbarians\").or_else(vikings), Some(\"barbarians\"));\nassert_eq!(None.or_else(vikings), Some(\"vikings\"));\nassert_eq!(None.or_else(nobody), None);
Returns Some
if exactly one of self
, optb
is Some
, otherwise returns None
.
let x = Some(2);\nlet y: Option<u32> = None;\nassert_eq!(x.xor(y), Some(2));\n\nlet x: Option<u32> = None;\nlet y = Some(2);\nassert_eq!(x.xor(y), Some(2));\n\nlet x = Some(2);\nlet y = Some(2);\nassert_eq!(x.xor(y), None);\n\nlet x: Option<u32> = None;\nlet y: Option<u32> = None;\nassert_eq!(x.xor(y), None);
Inserts value
into the option, then returns a mutable reference to it.
If the option already contains a value, the old value is dropped.
\nSee also Option::get_or_insert
, which doesn’t update the value if\nthe option already contains Some
.
let mut opt = None;\nlet val = opt.insert(1);\nassert_eq!(*val, 1);\nassert_eq!(opt.unwrap(), 1);\nlet val = opt.insert(2);\nassert_eq!(*val, 2);\n*val = 3;\nassert_eq!(opt.unwrap(), 3);
Inserts value
into the option if it is None
, then\nreturns a mutable reference to the contained value.
See also Option::insert
, which updates the value even if\nthe option already contains Some
.
let mut x = None;\n\n{\n let y: &mut u32 = x.get_or_insert(5);\n assert_eq!(y, &5);\n\n *y = 7;\n}\n\nassert_eq!(x, Some(7));
option_get_or_insert_default
)Inserts the default value into the option if it is None
, then\nreturns a mutable reference to the contained value.
#![feature(option_get_or_insert_default)]\n\nlet mut x = None;\n\n{\n let y: &mut u32 = x.get_or_insert_default();\n assert_eq!(y, &0);\n\n *y = 7;\n}\n\nassert_eq!(x, Some(7));
option_take_if
)Takes the value out of the option, but only if the predicate evaluates to\ntrue
on a mutable reference to the value.
In other words, replaces self
with None
if the predicate returns true
.\nThis method operates similar to Option::take
but conditional.
#![feature(option_take_if)]\n\nlet mut x = Some(42);\n\nlet prev = x.take_if(|v| if *v == 42 {\n *v += 1;\n false\n} else {\n false\n});\nassert_eq!(x, Some(43));\nassert_eq!(prev, None);\n\nlet prev = x.take_if(|v| *v == 43);\nassert_eq!(x, None);\nassert_eq!(prev, Some(43));
Replaces the actual value in the option by the value given in parameter,\nreturning the old value if present,\nleaving a Some
in its place without deinitializing either one.
let mut x = Some(2);\nlet old = x.replace(5);\nassert_eq!(x, Some(5));\nassert_eq!(old, Some(2));\n\nlet mut x = None;\nlet old = x.replace(3);\nassert_eq!(x, Some(3));\nassert_eq!(old, None);
Zips self
with another Option
.
If self
is Some(s)
and other
is Some(o)
, this method returns Some((s, o))
.\nOtherwise, None
is returned.
let x = Some(1);\nlet y = Some(\"hi\");\nlet z = None::<u8>;\n\nassert_eq!(x.zip(y), Some((1, \"hi\")));\nassert_eq!(x.zip(z), None);
option_zip
)Zips self
and another Option
with function f
.
If self
is Some(s)
and other
is Some(o)
, this method returns Some(f(s, o))
.\nOtherwise, None
is returned.
#![feature(option_zip)]\n\n#[derive(Debug, PartialEq)]\nstruct Point {\n x: f64,\n y: f64,\n}\n\nimpl Point {\n fn new(x: f64, y: f64) -> Self {\n Self { x, y }\n }\n}\n\nlet x = Some(17.5);\nlet y = Some(42.7);\n\nassert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17.5, y: 42.7 }));\nassert_eq!(x.zip_with(None, Point::new), None);
self
and other
) and is used by the <=
\noperator. Read moreTakes each element in the Iterator
: if it is None
,\nno further elements are taken, and the None
is\nreturned. Should no None
occur, a container of type\nV
containing the values of each Option
is returned.
Here is an example which increments every integer in a vector.\nWe use the checked variant of add
that returns None
when the\ncalculation would result in an overflow.
let items = vec![0_u16, 1, 2];\n\nlet res: Option<Vec<u16>> = items\n .iter()\n .map(|x| x.checked_add(1))\n .collect();\n\nassert_eq!(res, Some(vec![1, 2, 3]));
As you can see, this will return the expected, valid items.
\nHere is another example that tries to subtract one from another list\nof integers, this time checking for underflow:
\n\nlet items = vec![2_u16, 1, 0];\n\nlet res: Option<Vec<u16>> = items\n .iter()\n .map(|x| x.checked_sub(1))\n .collect();\n\nassert_eq!(res, None);
Since the last element is zero, it would underflow. Thus, the resulting\nvalue is None
.
Here is a variation on the previous example, showing that no\nfurther elements are taken from iter
after the first None
.
let items = vec![3_u16, 2, 1, 10];\n\nlet mut shared = 0;\n\nlet res: Option<Vec<u16>> = items\n .iter()\n .map(|x| { shared += x; x.checked_sub(2) })\n .collect();\n\nassert_eq!(res, None);\nassert_eq!(shared, 6);
Since the third element caused an underflow, no further elements were taken,\nso the final value of shared
is 6 (= 3 + 2 + 1
), not 16.