farmfe_core 2.1.0

Core types and data structures for farm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use serde::de::DeserializeOwned;

use super::Config;

pub fn get_field_or_default_from_custom<T: Default + DeserializeOwned>(
  config: &Config,
  field: &str,
) -> T {
  config
    .custom
    .get(field)
    .map(|val| serde_json::from_str(val).unwrap_or_default())
    .unwrap_or_default()
}