From c45446ba73b75949bd3b222a0003c257e9e00ff7 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Mon, 2 Nov 2020 19:28:50 -0800 Subject: [PATCH] Seal the `RowIndex` trait (technically breaking, but unlikely to break anybody) --- src/row.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/row.rs b/src/row.rs index 36aa1a6..7a8d4ae 100644 --- a/src/row.rs +++ b/src/row.rs @@ -346,8 +346,18 @@ impl<'stmt> Row<'stmt> { } } +mod sealed { + /// This trait exists just to ensure that the only impls of `trait Params` + /// that are allowed are ones in this crate. + pub trait Sealed {} + impl Sealed for usize {} + impl Sealed for &str {} +} + /// A trait implemented by types that can index into columns of a row. -pub trait RowIndex { +/// +/// It is only implemented for `usize` and `&str`. +pub trait RowIndex: sealed::Sealed { /// Returns the index of the appropriate column, or `None` if no such /// column exists. fn idx(&self, stmt: &Statement<'_>) -> Result;