🎨 Unifica conversiones a String con to_string()
Como `String::from()` y `.to_string()` son equivalentes, se sustituyen todas las ocurrencias de `String::from()` por `to_string()` para mayor coherencia y legibilidad.
This commit is contained in:
parent
b16c9378d0
commit
7179cf0831
12 changed files with 29 additions and 29 deletions
|
|
@ -129,7 +129,7 @@ impl Favicon {
|
|||
icon_color: Option<String>,
|
||||
) -> Self {
|
||||
let icon_type = match icon_source.rfind('.') {
|
||||
Some(i) => match icon_source[i..].to_owned().to_lowercase().as_str() {
|
||||
Some(i) => match icon_source[i..].to_string().to_lowercase().as_str() {
|
||||
".avif" => Some("image/avif"),
|
||||
".gif" => Some("image/gif"),
|
||||
".ico" => Some("image/x-icon"),
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub enum ClassesOp {
|
|||
/// .with_value(ClassesOp::Add, "Active")
|
||||
/// .with_value(ClassesOp::Remove, "btn-primary");
|
||||
///
|
||||
/// assert_eq!(classes.get(), Some(String::from("btn active")));
|
||||
/// assert_eq!(classes.get(), Some("btn active".to_string()));
|
||||
/// assert!(classes.contains("active"));
|
||||
/// ```
|
||||
#[derive(AutoDefault, Clone, Debug)]
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ use crate::{builder_fn, AutoDefault};
|
|||
/// // Español disponible.
|
||||
/// assert_eq!(
|
||||
/// hello.lookup(&LangMatch::resolve("es-ES")),
|
||||
/// Some(String::from("¡Hola mundo!"))
|
||||
/// Some("¡Hola mundo!".to_string())
|
||||
/// );
|
||||
///
|
||||
/// // Japonés no disponible, traduce al idioma de respaldo ("en-US").
|
||||
/// assert_eq!(
|
||||
/// hello.lookup(&LangMatch::resolve("ja-JP")),
|
||||
/// Some(String::from("Hello world!"))
|
||||
/// Some("Hello world!".to_string())
|
||||
/// );
|
||||
///
|
||||
/// // Uso típico en un atributo:
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ impl AttrValue {
|
|||
self.0 = if value.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(value.to_owned())
|
||||
Some(value.to_string())
|
||||
};
|
||||
self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ impl Context {
|
|||
///
|
||||
/// let cx = Context::new(None)
|
||||
/// .with_param("usuario_id", 42_i32)
|
||||
/// .with_param("titulo", String::from("Hola"));
|
||||
/// .with_param("titulo", "Hola".to_string());
|
||||
///
|
||||
/// let id: &i32 = cx.get_param("usuario_id").unwrap();
|
||||
/// let titulo: &String = cx.get_param("titulo").unwrap();
|
||||
|
|
@ -318,7 +318,7 @@ impl Context {
|
|||
///
|
||||
/// let mut cx = Context::new(None)
|
||||
/// .with_param("contador", 7_i32)
|
||||
/// .with_param("titulo", String::from("Hola"));
|
||||
/// .with_param("titulo", "Hola".to_string());
|
||||
///
|
||||
/// let n: i32 = cx.take_param("contador").unwrap();
|
||||
/// assert!(cx.get_param::<i32>("contador").is_err()); // ya no está
|
||||
|
|
@ -416,7 +416,7 @@ impl Contextual for Context {
|
|||
///
|
||||
/// let cx = Context::new(None)
|
||||
/// .with_param("usuario_id", 42_i32)
|
||||
/// .with_param("titulo", String::from("Hola"))
|
||||
/// .with_param("titulo", "Hola".to_string())
|
||||
/// .with_param("flags", vec!["a", "b"]);
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
|
|
@ -484,7 +484,7 @@ impl Contextual for Context {
|
|||
/// ```rust
|
||||
/// use pagetop::prelude::*;
|
||||
///
|
||||
/// let cx = Context::new(None).with_param("username", String::from("Alice"));
|
||||
/// let cx = Context::new(None).with_param("username", "Alice".to_string());
|
||||
///
|
||||
/// // Devuelve Some(&String) si existe y coincide el tipo.
|
||||
/// assert_eq!(cx.param::<String>("username").map(|s| s.as_str()), Some("Alice"));
|
||||
|
|
@ -533,7 +533,7 @@ impl Contextual for Context {
|
|||
.replace(' ', "_")
|
||||
.to_lowercase();
|
||||
let prefix = if prefix.is_empty() {
|
||||
"prefix".to_owned()
|
||||
"prefix".to_string()
|
||||
} else {
|
||||
prefix
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue