@@ -180,9 +180,11 @@ impl<T: Template + ?Sized> Template for &T {
180
180
const SIZE_HINT : usize = T :: SIZE_HINT ;
181
181
}
182
182
183
- /// Object-safe wrapper trait around [`Template`] implementers
183
+ /// [`dyn`-compatible] wrapper trait around [`Template`] implementers
184
184
///
185
- /// This trades reduced performance (mostly due to writing into `dyn Write`) for object safety.
185
+ /// This trades reduced performance (mostly due to writing into `dyn Write`) for dyn-compatibility.
186
+ ///
187
+ /// [`dyn`-compatible]: https://doc.rust-lang.org/stable/reference/items/traits.html#dyn-compatibility
186
188
pub trait DynTemplate {
187
189
/// Helper method which allocates a new `String` and renders into it
188
190
#[ cfg( feature = "alloc" ) ]
@@ -200,11 +202,13 @@ pub trait DynTemplate {
200
202
}
201
203
202
204
impl < T : Template > DynTemplate for T {
205
+ #[ inline]
203
206
#[ cfg( feature = "alloc" ) ]
204
207
fn dyn_render ( & self ) -> Result < String > {
205
208
<Self as Template >:: render ( self )
206
209
}
207
210
211
+ #[ inline]
208
212
fn dyn_render_into ( & self , writer : & mut dyn fmt:: Write ) -> Result < ( ) > {
209
213
<Self as Template >:: render_into ( self , writer)
210
214
}
@@ -215,12 +219,14 @@ impl<T: Template> DynTemplate for T {
215
219
<Self as Template >:: write_into ( self , writer)
216
220
}
217
221
222
+ #[ inline]
218
223
fn size_hint ( & self ) -> usize {
219
- Self :: SIZE_HINT
224
+ < Self as Template > :: SIZE_HINT
220
225
}
221
226
}
222
227
223
228
impl fmt:: Display for dyn DynTemplate {
229
+ #[ inline]
224
230
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
225
231
self . dyn_render_into ( f) . map_err ( |_| fmt:: Error { } )
226
232
}
0 commit comments