pub fn array_fill<E: SingleValue, value, dim>(
value: value,
dim: dim,
) -> array_fill<E, value, dim>
Available on crate feature
postgres_backend
only.Expand description
Returns an array initialized with supplied value and dimensions, optionally with lower bounds other than 1. This function omits the optional lower bound argument. See [array_fill_with_lower_bound] for that.
ยงExample
let array = diesel::select(array_fill::<Integer,_,_>(2,vec![2]))
.get_result::<Vec<i32>>(connection)?;
assert_eq!(vec![2,2],array);
let array = diesel::select(array_fill::<Text,_,_>(String::from("abc"),vec![3]))
.get_result::<Vec<String>>(connection)?;
assert_eq!(vec!["abc","abc","abc"],array);
let array = diesel::select(array_fill::<Nullable<Integer>,_,_>(Some(4),vec![3]))
.get_result::<Vec<Option<i32>>>(connection)?;
assert_eq!(vec![Some(4),Some(4),Some(4)],array);
let array = diesel::select(array_fill::<Nullable<Integer>,_,_>(None::<i32>,vec![3]))
.get_result::<Vec<Option<i32>>>(connection)?;
assert_eq!(vec![None::<i32>,None::<i32>,None::<i32>],array);