@@ -200,7 +200,7 @@ impl SqlFileDoc {
200200 let column_name = column. name . value . clone ( ) ;
201201 let column_doc = match column_leading {
202202 Some ( col_comment) => {
203- ColumnDoc :: new ( column_name, Some ( col_comment. text ( ) . to_string ( ) ) )
203+ ColumnDoc :: new ( column_name, Some ( col_comment. text ( ) . to_owned ( ) ) )
204204 }
205205 None => ColumnDoc :: new ( column_name, None ) ,
206206 } ;
@@ -211,7 +211,7 @@ impl SqlFileDoc {
211211 let table_doc = TableDoc :: new (
212212 schema,
213213 name,
214- table_leading. as_ref ( ) . map ( |c| c. text ( ) . to_string ( ) ) ,
214+ table_leading. as_ref ( ) . map ( |c| c. text ( ) . to_owned ( ) ) ,
215215 column_docs,
216216 file. path_into_path_buf ( ) ,
217217 ) ;
@@ -280,7 +280,7 @@ fn schema_and_table(name: &ObjectName) -> Result<(Option<String>, String), DocEr
280280 [ ] => {
281281 let span = name. span ( ) ;
282282 Err ( DocError :: InvalidObjectName {
283- message : "ObjectName had no identifier parts" . to_string ( ) ,
283+ message : "ObjectName had no identifier parts" . to_owned ( ) ,
284284 line : span. start . line ,
285285 column : span. start . column ,
286286 } )
@@ -307,12 +307,12 @@ mod tests {
307307
308308 #[ test]
309309 fn test_sql_docs_struct ( ) {
310- let column_doc = ColumnDoc :: new ( "id" . to_string ( ) , Some ( "The ID for the table" . to_string ( ) ) ) ;
310+ let column_doc = ColumnDoc :: new ( "id" . to_owned ( ) , Some ( "The ID for the table" . to_owned ( ) ) ) ;
311311 let columns = vec ! [ column_doc] ;
312312 let table_doc = TableDoc :: new (
313313 None ,
314- "user" . to_string ( ) ,
315- Some ( "The table for users" . to_string ( ) ) ,
314+ "user" . to_owned ( ) ,
315+ Some ( "The table for users" . to_owned ( ) ) ,
316316 columns,
317317 None ,
318318 ) ;
@@ -511,26 +511,26 @@ CREATE TABLE posts (
511511 SqlFileDoc :: new ( vec ! [
512512 TableDoc :: new(
513513 None ,
514- "users" . to_string ( ) ,
514+ "users" . to_owned ( ) ,
515515 None ,
516516 vec![
517- ColumnDoc :: new( "id" . to_string ( ) , None ) ,
518- ColumnDoc :: new( "username" . to_string ( ) , None ) ,
519- ColumnDoc :: new( "email" . to_string ( ) , None ) ,
520- ColumnDoc :: new( "created_at" . to_string ( ) , None ) ,
517+ ColumnDoc :: new( "id" . to_owned ( ) , None ) ,
518+ ColumnDoc :: new( "username" . to_owned ( ) , None ) ,
519+ ColumnDoc :: new( "email" . to_owned ( ) , None ) ,
520+ ColumnDoc :: new( "created_at" . to_owned ( ) , None ) ,
521521 ] ,
522522 None ,
523523 ) ,
524524 TableDoc :: new(
525525 None ,
526- "posts" . to_string ( ) ,
526+ "posts" . to_owned ( ) ,
527527 None ,
528528 vec![
529- ColumnDoc :: new( "id" . to_string ( ) , None ) ,
530- ColumnDoc :: new( "title" . to_string ( ) , None ) ,
531- ColumnDoc :: new( "user_id" . to_string ( ) , None ) ,
532- ColumnDoc :: new( "body" . to_string ( ) , None ) ,
533- ColumnDoc :: new( "published_at" . to_string ( ) , None ) ,
529+ ColumnDoc :: new( "id" . to_owned ( ) , None ) ,
530+ ColumnDoc :: new( "title" . to_owned ( ) , None ) ,
531+ ColumnDoc :: new( "user_id" . to_owned ( ) , None ) ,
532+ ColumnDoc :: new( "body" . to_owned ( ) , None ) ,
533+ ColumnDoc :: new( "published_at" . to_owned ( ) , None ) ,
534534 ] ,
535535 None ,
536536 ) ,
@@ -543,34 +543,34 @@ CREATE TABLE posts (
543543 let first_docs = SqlFileDoc :: new ( vec ! [
544544 TableDoc :: new(
545545 None ,
546- "users" . to_string ( ) ,
547- Some ( "Users table stores user account information" . to_string ( ) ) ,
546+ "users" . to_owned ( ) ,
547+ Some ( "Users table stores user account information" . to_owned ( ) ) ,
548548 vec![
549- ColumnDoc :: new( "id" . to_string ( ) , Some ( "Primary key" . to_string ( ) ) ) ,
550- ColumnDoc :: new( "username" . to_string ( ) , Some ( "Username for login" . to_string ( ) ) ) ,
551- ColumnDoc :: new( "email" . to_string ( ) , Some ( "Email address" . to_string ( ) ) ) ,
549+ ColumnDoc :: new( "id" . to_owned ( ) , Some ( "Primary key" . to_owned ( ) ) ) ,
550+ ColumnDoc :: new( "username" . to_owned ( ) , Some ( "Username for login" . to_owned ( ) ) ) ,
551+ ColumnDoc :: new( "email" . to_owned ( ) , Some ( "Email address" . to_owned ( ) ) ) ,
552552 ColumnDoc :: new(
553- "created_at" . to_string ( ) ,
554- Some ( "When the user registered" . to_string ( ) ) ,
553+ "created_at" . to_owned ( ) ,
554+ Some ( "When the user registered" . to_owned ( ) ) ,
555555 ) ,
556556 ] ,
557557 None ,
558558 ) ,
559559 TableDoc :: new(
560560 None ,
561- "posts" . to_string ( ) ,
562- Some ( "Posts table stores blog posts" . to_string ( ) ) ,
561+ "posts" . to_owned ( ) ,
562+ Some ( "Posts table stores blog posts" . to_owned ( ) ) ,
563563 vec![
564- ColumnDoc :: new( "id" . to_string ( ) , Some ( "Primary key" . to_string ( ) ) ) ,
565- ColumnDoc :: new( "title" . to_string ( ) , Some ( "Post title" . to_string ( ) ) ) ,
564+ ColumnDoc :: new( "id" . to_owned ( ) , Some ( "Primary key" . to_owned ( ) ) ) ,
565+ ColumnDoc :: new( "title" . to_owned ( ) , Some ( "Post title" . to_owned ( ) ) ) ,
566566 ColumnDoc :: new(
567- "user_id" . to_string ( ) ,
568- Some ( "Foreign key linking to users" . to_string ( ) ) ,
567+ "user_id" . to_owned ( ) ,
568+ Some ( "Foreign key linking to users" . to_owned ( ) ) ,
569569 ) ,
570- ColumnDoc :: new( "body" . to_string ( ) , Some ( "Main body text" . to_string ( ) ) ) ,
570+ ColumnDoc :: new( "body" . to_owned ( ) , Some ( "Main body text" . to_owned ( ) ) ) ,
571571 ColumnDoc :: new(
572- "published_at" . to_string ( ) ,
573- Some ( "When the post was created" . to_string ( ) ) ,
572+ "published_at" . to_owned ( ) ,
573+ Some ( "When the post was created" . to_owned ( ) ) ,
574574 ) ,
575575 ] ,
576576 None ,
@@ -581,43 +581,37 @@ CREATE TABLE posts (
581581 let second_docs = SqlFileDoc :: new ( vec ! [
582582 TableDoc :: new(
583583 None ,
584- "users" . to_string ( ) ,
585- Some ( "Users table stores user account information\n multiline" . to_string ( ) ) ,
584+ "users" . to_owned ( ) ,
585+ Some ( "Users table stores user account information\n multiline" . to_owned ( ) ) ,
586586 vec![
587- ColumnDoc :: new( "id" . to_string ( ) , Some ( "Primary key\n multiline" . to_string ( ) ) ) ,
587+ ColumnDoc :: new( "id" . to_owned ( ) , Some ( "Primary key\n multiline" . to_owned ( ) ) ) ,
588588 ColumnDoc :: new(
589- "username" . to_string ( ) ,
590- Some ( "Username for login\n multiline" . to_string ( ) ) ,
589+ "username" . to_owned ( ) ,
590+ Some ( "Username for login\n multiline" . to_owned ( ) ) ,
591591 ) ,
592+ ColumnDoc :: new( "email" . to_owned( ) , Some ( "Email address\n multiline" . to_owned( ) ) ) ,
592593 ColumnDoc :: new(
593- "email" . to_string( ) ,
594- Some ( "Email address\n multiline" . to_string( ) ) ,
595- ) ,
596- ColumnDoc :: new(
597- "created_at" . to_string( ) ,
598- Some ( "When the user registered\n multiline" . to_string( ) ) ,
594+ "created_at" . to_owned( ) ,
595+ Some ( "When the user registered\n multiline" . to_owned( ) ) ,
599596 ) ,
600597 ] ,
601598 None ,
602599 ) ,
603600 TableDoc :: new(
604601 None ,
605- "posts" . to_string ( ) ,
606- Some ( "Posts table stores blog posts\n multiline" . to_string ( ) ) ,
602+ "posts" . to_owned ( ) ,
603+ Some ( "Posts table stores blog posts\n multiline" . to_owned ( ) ) ,
607604 vec![
608- ColumnDoc :: new( "id" . to_string( ) , Some ( "Primary key\n multiline" . to_string( ) ) ) ,
609- ColumnDoc :: new( "title" . to_string( ) , Some ( "Post title\n multiline" . to_string( ) ) ) ,
610- ColumnDoc :: new(
611- "user_id" . to_string( ) ,
612- Some ( "Foreign key linking to users\n multiline" . to_string( ) ) ,
613- ) ,
605+ ColumnDoc :: new( "id" . to_owned( ) , Some ( "Primary key\n multiline" . to_owned( ) ) ) ,
606+ ColumnDoc :: new( "title" . to_owned( ) , Some ( "Post title\n multiline" . to_owned( ) ) ) ,
614607 ColumnDoc :: new(
615- "body" . to_string ( ) ,
616- Some ( "Main body text \n multiline" . to_string ( ) ) ,
608+ "user_id" . to_owned ( ) ,
609+ Some ( "Foreign key linking to users \n multiline" . to_owned ( ) ) ,
617610 ) ,
611+ ColumnDoc :: new( "body" . to_owned( ) , Some ( "Main body text\n multiline" . to_owned( ) ) ) ,
618612 ColumnDoc :: new(
619- "published_at" . to_string ( ) ,
620- Some ( "When the post was created\n multiline" . to_string ( ) ) ,
613+ "published_at" . to_owned ( ) ,
614+ Some ( "When the post was created\n multiline" . to_owned ( ) ) ,
621615 ) ,
622616 ] ,
623617 None ,
@@ -630,26 +624,26 @@ CREATE TABLE posts (
630624
631625 #[ test]
632626 fn test_doc ( ) {
633- let col_doc = ColumnDoc :: new ( "test" . to_string ( ) , Some ( "comment" . to_string ( ) ) ) ;
634- assert_eq ! ( & col_doc. to_string( ) , & "Column Name: test\n Column Doc: comment\n " . to_string ( ) ) ;
635- let col_doc_no_doc = ColumnDoc :: new ( "test" . to_string ( ) , None ) ;
627+ let col_doc = ColumnDoc :: new ( "test" . to_owned ( ) , Some ( "comment" . to_owned ( ) ) ) ;
628+ assert_eq ! ( & col_doc. to_string( ) , & "Column Name: test\n Column Doc: comment\n " . to_owned ( ) ) ;
629+ let col_doc_no_doc = ColumnDoc :: new ( "test" . to_owned ( ) , None ) ;
636630 assert_eq ! (
637631 & col_doc_no_doc. to_string( ) ,
638- & "Column Name: test\n No Column Doc Found\n " . to_string ( )
632+ & "Column Name: test\n No Column Doc Found\n " . to_owned ( )
639633 ) ;
640634 assert_eq ! ( col_doc. doc( ) , Some ( "comment" ) ) ;
641635 assert_eq ! ( col_doc. name( ) , "test" ) ;
642636 assert_eq ! ( col_doc_no_doc. doc( ) , None ) ;
643637 assert_eq ! ( col_doc_no_doc. name( ) , "test" ) ;
644638 let table_doc = TableDoc :: new (
645- Some ( "schema" . to_string ( ) ) ,
646- "table" . to_string ( ) ,
647- Some ( "table doc" . to_string ( ) ) ,
639+ Some ( "schema" . to_owned ( ) ) ,
640+ "table" . to_owned ( ) ,
641+ Some ( "table doc" . to_owned ( ) ) ,
648642 vec ! [ col_doc] ,
649643 None ,
650644 ) ;
651645 let table_doc_no_doc =
652- TableDoc :: new ( None , "table" . to_string ( ) , None , vec ! [ col_doc_no_doc] , None ) ;
646+ TableDoc :: new ( None , "table" . to_owned ( ) , None , vec ! [ col_doc_no_doc] , None ) ;
653647 assert_eq ! ( table_doc. name( ) , "table" ) ;
654648 assert_eq ! ( table_doc. schema( ) , Some ( "schema" ) ) ;
655649 assert_eq ! (
@@ -665,7 +659,7 @@ CREATE TABLE posts (
665659 }
666660
667661 fn ident ( v : & str ) -> Ident {
668- Ident { value : v. to_string ( ) , quote_style : None , span : Span :: empty ( ) }
662+ Ident { value : v. to_owned ( ) , quote_style : None , span : Span :: empty ( ) }
669663 }
670664
671665 fn func_part ( name : & str ) -> ObjectNamePart {
@@ -713,7 +707,7 @@ CREATE TABLE posts (
713707 ] ) ;
714708
715709 let ( schema, table) = schema_and_table ( & name) ?;
716- assert_eq ! ( schema, Some ( "public" . to_string ( ) ) ) ;
710+ assert_eq ! ( schema, Some ( "public" . to_owned ( ) ) ) ;
717711 assert_eq ! ( table, "orders" ) ;
718712 Ok ( ( ) )
719713 }
@@ -785,7 +779,7 @@ CREATE TABLE posts (
785779
786780 #[ test]
787781 fn column_doc_set_doc_updates_doc ( ) {
788- let mut col = ColumnDoc :: new ( "id" . to_string ( ) , None ) ;
782+ let mut col = ColumnDoc :: new ( "id" . to_owned ( ) , None ) ;
789783 assert_eq ! ( col. name( ) , "id" ) ;
790784 assert_eq ! ( col. doc( ) , None ) ;
791785 col. set_doc ( "primary key" ) ;
@@ -797,7 +791,7 @@ CREATE TABLE posts (
797791
798792 #[ test]
799793 fn table_doc_set_doc_updates_doc ( ) {
800- let mut table = TableDoc :: new ( None , "users" . to_string ( ) , None , Vec :: new ( ) , None ) ;
794+ let mut table = TableDoc :: new ( None , "users" . to_owned ( ) , None , Vec :: new ( ) , None ) ;
801795 assert_eq ! ( table. name( ) , "users" ) ;
802796 assert_eq ! ( table. schema( ) , None ) ;
803797 assert_eq ! ( table. doc( ) , None ) ;
@@ -811,11 +805,11 @@ CREATE TABLE posts (
811805 fn columns_mut_allows_mutating_column_docs ( ) {
812806 let mut table = TableDoc :: new (
813807 None ,
814- "users" . to_string ( ) ,
808+ "users" . to_owned ( ) ,
815809 None ,
816810 vec ! [
817- ColumnDoc :: new( "id" . to_string ( ) , None ) ,
818- ColumnDoc :: new( "username" . to_string ( ) , None ) ,
811+ ColumnDoc :: new( "id" . to_owned ( ) , None ) ,
812+ ColumnDoc :: new( "username" . to_owned ( ) , None ) ,
819813 ] ,
820814 None ,
821815 ) ;
@@ -837,16 +831,16 @@ CREATE TABLE posts (
837831 fn test_from_sql_file_doc_into_vec_table_doc_preserves_contents_and_order ( ) {
838832 let t1 = TableDoc :: new (
839833 None ,
840- "users" . to_string ( ) ,
841- Some ( "users doc" . to_string ( ) ) ,
842- vec ! [ ColumnDoc :: new( "id" . to_string ( ) , Some ( "pk" . to_string ( ) ) ) ] ,
834+ "users" . to_owned ( ) ,
835+ Some ( "users doc" . to_owned ( ) ) ,
836+ vec ! [ ColumnDoc :: new( "id" . to_owned ( ) , Some ( "pk" . to_owned ( ) ) ) ] ,
843837 None ,
844838 ) ;
845839 let t2 = TableDoc :: new (
846- Some ( "analytics" . to_string ( ) ) ,
847- "events" . to_string ( ) ,
840+ Some ( "analytics" . to_owned ( ) ) ,
841+ "events" . to_owned ( ) ,
848842 None ,
849- vec ! [ ColumnDoc :: new( "payload" . to_string ( ) , None ) ] ,
843+ vec ! [ ColumnDoc :: new( "payload" . to_owned ( ) , None ) ] ,
850844 None ,
851845 ) ;
852846
@@ -858,7 +852,7 @@ CREATE TABLE posts (
858852 }
859853 #[ test]
860854 fn table_doc_path_getter_returns_expected_value ( ) {
861- let mut table = TableDoc :: new ( None , "users" . to_string ( ) , None , Vec :: new ( ) , None ) ;
855+ let mut table = TableDoc :: new ( None , "users" . to_owned ( ) , None , Vec :: new ( ) , None ) ;
862856 assert_eq ! ( table. path( ) , None ) ;
863857 let pb = PathBuf :: from ( "some/dir/file.sql" ) ;
864858 table. set_path ( Some ( pb. clone ( ) ) ) ;
0 commit comments