mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 06:51:15 +00:00
Merge pull request #270 from Kijewski/pr-saturating
`std::num::Saturating` is stable since rust 1.74
This commit is contained in:
commit
067fd379b8
@ -153,18 +153,18 @@ where
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::cell::Cell;
|
/// # use std::cell::Cell;
|
||||||
/// # use std::num::NonZeroI16;
|
/// # use std::num::{NonZeroI16, Saturating};
|
||||||
/// # use std::rc::Rc;
|
/// # use std::rc::Rc;
|
||||||
/// # use std::pin::Pin;
|
/// # use std::pin::Pin;
|
||||||
/// # use rinja::Template;
|
/// # use rinja::Template;
|
||||||
/// #[derive(Template)]
|
/// #[derive(Template)]
|
||||||
/// #[template(ext = "txt", source = "{{ value as u16 }}")]
|
/// #[template(ext = "txt", source = "{{ value as u16 }}")]
|
||||||
/// struct Test<'a> {
|
/// struct Test<'a> {
|
||||||
/// value: &'a Pin<Rc<Cell<NonZeroI16>>>
|
/// value: &'a Pin<Rc<Cell<Saturating<NonZeroI16>>>>
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// Test { value: &Rc::pin(Cell::new(NonZeroI16::new(-1).unwrap())) }.to_string(),
|
/// Test { value: &Rc::pin(Cell::new(Saturating(NonZeroI16::new(-1).unwrap()))) }.to_string(),
|
||||||
/// "65535",
|
/// "65535",
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
@ -186,6 +186,15 @@ impl<T: PrimitiveType> PrimitiveType for std::num::Wrapping<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: PrimitiveType> PrimitiveType for std::num::Saturating<T> {
|
||||||
|
type Value = T::Value;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn get(&self) -> Self::Value {
|
||||||
|
self.0.get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! primitize_nz {
|
macro_rules! primitize_nz {
|
||||||
($($nz:ty => $bare:ident,)+) => { $(
|
($($nz:ty => $bare:ident,)+) => { $(
|
||||||
impl PrimitiveType for $nz {
|
impl PrimitiveType for $nz {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user