From a6e086889038076ec0b6b16af1ddefb50f187b8b Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Thu, 21 Jul 2022 09:26:23 -0400 Subject: [PATCH] Setting up to give FieldType a new function. --- src/morethantext/fieldtype.rs | 13 +++++-------- src/morethantext/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/morethantext/fieldtype.rs b/src/morethantext/fieldtype.rs index 6b79eca..ec20675 100644 --- a/src/morethantext/fieldtype.rs +++ b/src/morethantext/fieldtype.rs @@ -19,9 +19,9 @@ pub struct StaticString { } impl StaticString { - pub fn new(data: &str) -> FieldType { + pub fn new() -> FieldType { FieldType::StaticString(Self { - data: data.to_string(), + data: "".to_string(), }) } } @@ -38,13 +38,10 @@ mod staticstrings { #[test] fn create_static_string() { - let data = "fred"; - let field = StaticString::new(data); + let field = StaticString::new(); assert!( - field.to_string() == data, - "\n\nGot: {}\nWant: {}\n\n", - field.to_string(), - data + field.to_string() == "", + "New should return an empty string." ); } } diff --git a/src/morethantext/mod.rs b/src/morethantext/mod.rs index a6879f3..7f9936c 100644 --- a/src/morethantext/mod.rs +++ b/src/morethantext/mod.rs @@ -237,8 +237,8 @@ mod records { async fn update_fields() { let rec = Record::new(); let name = "elephant"; - let data = "Something to remember."; - let sstr = StaticString::new(data); + let data = ""; + let sstr = StaticString::new(); rec.update_field(name.to_string(), sstr).await; let output = rec.get_field(name).await.unwrap(); assert!(