Make (De)SerializeOptions as const
This commit is contained in:
parent
d88a4282c7
commit
0741db7565
|
@ -45,23 +45,23 @@ pub struct Options {
|
||||||
|
|
||||||
impl Default for Options {
|
impl Default for Options {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Options {
|
Self::new()
|
||||||
deny_unsupported_types: true,
|
|
||||||
deny_recursive_tables: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
/// Returns a new instance of `Options` with default parameters.
|
/// Returns a new instance of `Options` with default parameters.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Options {
|
||||||
|
deny_unsupported_types: true,
|
||||||
|
deny_recursive_tables: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets [`deny_unsupported_types`] option.
|
/// Sets [`deny_unsupported_types`] option.
|
||||||
///
|
///
|
||||||
/// [`deny_unsupported_types`]: #structfield.deny_unsupported_types
|
/// [`deny_unsupported_types`]: #structfield.deny_unsupported_types
|
||||||
pub fn deny_unsupported_types(mut self, enabled: bool) -> Self {
|
pub const fn deny_unsupported_types(mut self, enabled: bool) -> Self {
|
||||||
self.deny_unsupported_types = enabled;
|
self.deny_unsupported_types = enabled;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,24 +52,24 @@ pub struct Options {
|
||||||
|
|
||||||
impl Default for Options {
|
impl Default for Options {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Options {
|
||||||
|
/// Returns a new instance of [`Options`] with default parameters.
|
||||||
|
pub const fn new() -> Self {
|
||||||
Options {
|
Options {
|
||||||
set_array_metatable: true,
|
set_array_metatable: true,
|
||||||
serialize_none_to_null: true,
|
serialize_none_to_null: true,
|
||||||
serialize_unit_to_null: true,
|
serialize_unit_to_null: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Options {
|
|
||||||
/// Returns a new instance of [`Options`] with default parameters.
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets [`set_array_metatable`] option.
|
/// Sets [`set_array_metatable`] option.
|
||||||
///
|
///
|
||||||
/// [`set_array_metatable`]: #structfield.set_array_metatable
|
/// [`set_array_metatable`]: #structfield.set_array_metatable
|
||||||
pub fn set_array_metatable(mut self, enabled: bool) -> Self {
|
pub const fn set_array_metatable(mut self, enabled: bool) -> Self {
|
||||||
self.set_array_metatable = enabled;
|
self.set_array_metatable = enabled;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ impl Options {
|
||||||
/// Sets [`serialize_none_to_null`] option.
|
/// Sets [`serialize_none_to_null`] option.
|
||||||
///
|
///
|
||||||
/// [`serialize_none_to_null`]: #structfield.serialize_none_to_null
|
/// [`serialize_none_to_null`]: #structfield.serialize_none_to_null
|
||||||
pub fn serialize_none_to_null(mut self, enabled: bool) -> Self {
|
pub const fn serialize_none_to_null(mut self, enabled: bool) -> Self {
|
||||||
self.serialize_none_to_null = enabled;
|
self.serialize_none_to_null = enabled;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ impl Options {
|
||||||
/// Sets [`serialize_unit_to_null`] option.
|
/// Sets [`serialize_unit_to_null`] option.
|
||||||
///
|
///
|
||||||
/// [`serialize_unit_to_null`]: #structfield.serialize_unit_to_null
|
/// [`serialize_unit_to_null`]: #structfield.serialize_unit_to_null
|
||||||
pub fn serialize_unit_to_null(mut self, enabled: bool) -> Self {
|
pub const fn serialize_unit_to_null(mut self, enabled: bool) -> Self {
|
||||||
self.serialize_unit_to_null = enabled;
|
self.serialize_unit_to_null = enabled;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue