tcdi / plrust

A Rust procedural language handler for PostgreSQL
PostgreSQL License
1.12k stars 32 forks source link

`AnyNumeric` really wants `impl std::iter::Sum` #284

Closed eeeebbbbrrrr closed 1 year ago

eeeebbbbrrrr commented 1 year ago

It would be nice if pgrx implemented impl std::iter::Sum -- would make AnyNumeric easier to use here in plrust land.

eeeebbbbrrrr commented 1 year ago

well, would ya look at that: https://github.com/tcdi/pgrx/pull/1117

eeeebbbbrrrr commented 1 year ago

This got taken care of as part of https://github.com/tcdi/plrust/pull/297

[v14.7][1841693] plrust=# create function sum_array(a numeric[]) returns numeric strict language plrust as $$ Ok(Some(a.into_iter().map(|e| e.unwrap()).sum()))
$$;
CREATE FUNCTION

[v14.7][1841693] plrust=# select sum_array(ARRAY[1, 2.0, 3.5]);
 sum_array 
-----------
       6.5
(1 row)