From 6ae3918eb105dcaac9289238f919ec7f1493fd6f Mon Sep 17 00:00:00 2001 From: Dimitri Sabadie Date: Tue, 23 Apr 2019 12:34:24 +0200 Subject: [PATCH] Second pass of doc cleanup. --- src/interpolation.rs | 12 +++++++++--- src/iter.rs | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/interpolation.rs b/src/interpolation.rs index 54f97d0..85f5860 100644 --- a/src/interpolation.rs +++ b/src/interpolation.rs @@ -1,17 +1,23 @@ +//! Available interpolation modes. + #[cfg(feature = "serialization")] use serde_derive::{Deserialize, Serialize}; -/// Interpolation mode. +/// Available kind of interpolations. +/// +/// Feel free to visit each variant for more documentation. #[derive(Copy, Clone, Debug)] #[cfg_attr(feature = "serialization", derive(Deserialize, Serialize))] #[cfg_attr(feature = "serialization", serde(rename_all = "snake_case"))] pub enum Interpolation { - /// Hold a [`Key`] until the interpolator value passes the normalized step threshold, in which + /// Hold a [`Key`] until the sampling value passes the normalized step threshold, in which /// case the next key is used. /// /// > Note: if you set the threshold to `0.5`, the first key will be used until half the time /// > between the two keys; the second key will be in used afterwards. If you set it to `1.0`, the /// > first key will be kept until the next key. Set it to `0.` and the first key will never be /// > used. + /// + /// [`Key`]: crate::key::Key Step(T), /// Linear interpolation between a key and the next one. Linear, @@ -22,7 +28,7 @@ pub enum Interpolation { } impl Default for Interpolation { - /// `Interpolation::Linear` is the default. + /// [`Interpolation::Linear`] is the default. fn default() -> Self { Interpolation::Linear } diff --git a/src/iter.rs b/src/iter.rs index 85c7b3d..a342194 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,10 +1,18 @@ +//! Spline [`Iterator`], in a nutshell. +//! +//! You can iterate over a [`Spline`]’s keys with the [`IntoIterator`] trait on +//! `&Spline`. This gives you iterated [`Key`] keys. +//! +//! [`Spline`]: crate::spline::Spline +//! [`Key`]: crate::key::Key + use crate::{Key, Spline}; /// Iterator over spline keys. /// -/// This iterator type assures you to iterate over sorted keys. +/// This iterator type is guaranteed to iterate over sorted keys. pub struct Iter<'a, T, V> where T: 'a, V: 'a { - anim_param: &'a Spline, + spline: &'a Spline, i: usize } @@ -12,7 +20,7 @@ impl<'a, T, V> Iterator for Iter<'a, T, V> { type Item = &'a Key; fn next(&mut self) -> Option { - let r = self.anim_param.0.get(self.i); + let r = self.spline.0.get(self.i); if let Some(_) = r { self.i += 1; @@ -28,7 +36,7 @@ impl<'a, T, V> IntoIterator for &'a Spline { fn into_iter(self) -> Self::IntoIter { Iter { - anim_param: self, + spline: self, i: 0 } }