Skip to content

Commit 20cd1d7

Browse files
authored
Implement Default for Color and Annotations (#9)
* impl Default for response::Color A bit of a shock I didn't implement this already * impl Default for Annotations * Update response tests to use Annotations Default * Update render tests to use Annotations Default
1 parent daa9f8f commit 20cd1d7

File tree

2 files changed

+46
-299
lines changed

2 files changed

+46
-299
lines changed

src/render.rs

+21-168
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,7 @@ mod tests {
467467
text: vec![RichText {
468468
plain_text: "Cool test".to_string(),
469469
href: None,
470-
annotations: Annotations {
471-
bold: false,
472-
italic: false,
473-
strikethrough: false,
474-
underline: false,
475-
code: false,
476-
color: Color::Default,
477-
},
470+
annotations: Default::default(),
478471
ty: RichTextType::Text {
479472
content: "Cool test".to_string(),
480473
link: None,
@@ -502,14 +495,7 @@ mod tests {
502495
text: vec![RichText {
503496
plain_text: "Cooler test".to_string(),
504497
href: None,
505-
annotations: Annotations {
506-
bold: false,
507-
italic: false,
508-
strikethrough: false,
509-
underline: false,
510-
code: false,
511-
color: Color::Default,
512-
},
498+
annotations: Default::default(),
513499
ty: RichTextType::Text {
514500
content: "Cooler test".to_string(),
515501
link: None,
@@ -537,14 +523,7 @@ mod tests {
537523
text: vec![RichText {
538524
plain_text: "Coolest test".to_string(),
539525
href: None,
540-
annotations: Annotations {
541-
bold: false,
542-
italic: false,
543-
strikethrough: false,
544-
underline: false,
545-
code: false,
546-
color: Color::Default,
547-
},
526+
annotations: Default::default(),
548527
ty: RichTextType::Text {
549528
content: "Coolest test".to_string(),
550529
link: None,
@@ -594,14 +573,7 @@ mod tests {
594573
text: vec![RichText {
595574
plain_text: "Cool test".to_string(),
596575
href: None,
597-
annotations: Annotations {
598-
bold: false,
599-
italic: false,
600-
strikethrough: false,
601-
underline: false,
602-
code: false,
603-
color: Color::Default,
604-
},
576+
annotations: Default::default(),
605577
ty: RichTextType::Text {
606578
content: "Cool test".to_string(),
607579
link: None,
@@ -631,14 +603,7 @@ mod tests {
631603
RichText {
632604
plain_text: "Or you can just leave an empty line in between if you want it to leave extra breathing room.".to_string(),
633605
href: None,
634-
annotations: Annotations {
635-
bold: false,
636-
italic: false,
637-
strikethrough: false,
638-
underline: false,
639-
code: false,
640-
color: Color::Default,
641-
},
606+
annotations: Default::default(),
642607
ty: RichTextType::Text {
643608
content: "Or you can just leave an empty line in between if you want it to leave extra breathing room.".to_string(),
644609
link: None,
@@ -658,14 +623,7 @@ mod tests {
658623
RichText {
659624
plain_text: "You can also create these rather interesting nested paragraphs".to_string(),
660625
href: None,
661-
annotations: Annotations {
662-
bold: false,
663-
italic: false,
664-
strikethrough: false,
665-
underline: false,
666-
code: false,
667-
color: Color::Default,
668-
},
626+
annotations: Default::default(),
669627
ty: RichTextType::Text {
670628
content: "You can also create these rather interesting nested paragraphs".to_string(),
671629
link: None,
@@ -685,14 +643,7 @@ mod tests {
685643
RichText {
686644
plain_text: "Possibly more than once too!".to_string(),
687645
href: None,
688-
annotations: Annotations {
689-
bold: false,
690-
italic: false,
691-
strikethrough: false,
692-
underline: false,
693-
code: false,
694-
color: Color::Default,
695-
},
646+
annotations: Default::default(),
696647
ty: RichTextType::Text {
697648
content: "Possibly more than once too!".to_string(),
698649
link: None,
@@ -733,14 +684,7 @@ mod tests {
733684
RichText {
734685
plain_text: "If you think you can do a thing or think you can’t do a thing, you’re right.\n—Henry Ford".to_string(),
735686
href: None,
736-
annotations: Annotations {
737-
bold: false,
738-
italic: false,
739-
strikethrough: false,
740-
underline: false,
741-
code: false,
742-
color: Color::Default,
743-
},
687+
annotations: Default::default(),
744688
ty: RichTextType::Text {
745689
content: "If you think you can do a thing or think you can’t do a thing, you’re right.\n—Henry Ford".to_string(),
746690
link: None,
@@ -777,14 +721,7 @@ mod tests {
777721
RichText {
778722
plain_text: "struct Magic<T> {\n value: T\n}\n\nfn cool() -> Magic<T> {\n return Magic {\n value: 100\n };\n}".to_string(),
779723
href: None,
780-
annotations: Annotations {
781-
bold: false,
782-
italic: false,
783-
strikethrough: false,
784-
underline: false,
785-
code: false,
786-
color: Color::Default,
787-
},
724+
annotations: Default::default(),
788725
ty: RichTextType::Text {
789726
content: "struct Magic<T> {\n value: T\n}\n\nfn cool() -> Magic<T> {\n return Magic {\n value: 100\n };\n}".to_string(),
790727
link: None,
@@ -836,14 +773,7 @@ mod tests {
836773
text: vec![RichText {
837774
plain_text: "This is some cool list".to_string(),
838775
href: None,
839-
annotations: Annotations {
840-
bold: false,
841-
italic: false,
842-
strikethrough: false,
843-
underline: false,
844-
code: false,
845-
color: Color::Default,
846-
},
776+
annotations: Default::default(),
847777
ty: RichTextType::Text {
848778
content: "This is some cool list".to_string(),
849779
link: None,
@@ -860,14 +790,7 @@ mod tests {
860790
text: vec![RichText {
861791
plain_text: "It can even contain other lists inside of it".to_string(),
862792
href: None,
863-
annotations: Annotations {
864-
bold: false,
865-
italic: false,
866-
strikethrough: false,
867-
underline: false,
868-
code: false,
869-
color: Color::Default,
870-
},
793+
annotations: Default::default(),
871794
ty: RichTextType::Text {
872795
content: "It can even contain other lists inside of it".to_string(),
873796
link: None,
@@ -885,14 +808,7 @@ mod tests {
885808
plain_text: "And those lists can contain OTHER LISTS!"
886809
.to_string(),
887810
href: None,
888-
annotations: Annotations {
889-
bold: false,
890-
italic: false,
891-
strikethrough: false,
892-
underline: false,
893-
code: false,
894-
color: Color::Default,
895-
},
811+
annotations: Default::default(),
896812
ty: RichTextType::Text {
897813
content: "And those lists can contain OTHER LISTS!"
898814
.to_string(),
@@ -911,14 +827,7 @@ mod tests {
911827
text: vec![RichText {
912828
plain_text: "Listception".to_string(),
913829
href: None,
914-
annotations: Annotations {
915-
bold: false,
916-
italic: false,
917-
strikethrough: false,
918-
underline: false,
919-
code: false,
920-
color: Color::Default,
921-
},
830+
annotations: Default::default(),
922831
ty: RichTextType::Text {
923832
content: "Listception".to_string(),
924833
link: None,
@@ -938,14 +847,7 @@ mod tests {
938847
text: vec![RichText {
939848
plain_text: "Listception".to_string(),
940849
href: None,
941-
annotations: Annotations {
942-
bold: false,
943-
italic: false,
944-
strikethrough: false,
945-
underline: false,
946-
code: false,
947-
color: Color::Default,
948-
},
850+
annotations: Default::default(),
949851
ty: RichTextType::Text {
950852
content: "Listception".to_string(),
951853
link: None,
@@ -991,14 +893,7 @@ mod tests {
991893
RichText {
992894
plain_text: "Circle rendered in Bevy".to_string(),
993895
href: None,
994-
annotations: Annotations {
995-
bold: false,
996-
italic: false,
997-
strikethrough: false,
998-
underline: false,
999-
code: false,
1000-
color: Color::Default,
1001-
},
896+
annotations: Default::default(),
1002897
ty: RichTextType::Text {
1003898
content: "Circle rendered in Bevy".to_string(),
1004899
link: None,
@@ -1071,14 +966,7 @@ mod tests {
1071966
text: vec![RichText {
1072967
plain_text: "Some really spooky callout.".to_string(),
1073968
href: None,
1074-
annotations: Annotations {
1075-
bold: false,
1076-
italic: false,
1077-
strikethrough: false,
1078-
underline: false,
1079-
code: false,
1080-
color: Color::Default,
1081-
},
969+
annotations: Default::default(),
1082970
ty: RichTextType::Text {
1083971
content: "Some really spooky callout.".to_string(),
1084972
link: None,
@@ -1101,14 +989,7 @@ mod tests {
1101989
text: vec![RichText {
1102990
plain_text: "Some really spooky callout.".to_string(),
1103991
href: None,
1104-
annotations: Annotations {
1105-
bold: false,
1106-
italic: false,
1107-
strikethrough: false,
1108-
underline: false,
1109-
code: false,
1110-
color: Color::Default,
1111-
},
992+
annotations: Default::default(),
1112993
ty: RichTextType::Text {
1113994
content: "Some really spooky callout.".to_string(),
1114995
link: None,
@@ -1132,14 +1013,7 @@ mod tests {
11321013
text: vec![RichText {
11331014
plain_text: "Some really spooky callout.".to_string(),
11341015
href: None,
1135-
annotations: Annotations {
1136-
bold: false,
1137-
italic: false,
1138-
strikethrough: false,
1139-
underline: false,
1140-
code: false,
1141-
color: Color::Default,
1142-
},
1016+
annotations: Default::default(),
11431017
ty: RichTextType::Text {
11441018
content: "Some really spooky callout.".to_string(),
11451019
link: None,
@@ -1194,14 +1068,7 @@ mod tests {
11941068
let text = RichText {
11951069
href: None,
11961070
plain_text: "I love you!".to_string(),
1197-
annotations: Annotations {
1198-
bold: false,
1199-
italic: false,
1200-
strikethrough: false,
1201-
underline: false,
1202-
code: false,
1203-
color: Color::Default,
1204-
},
1071+
annotations: Default::default(),
12051072
ty: RichTextType::Text {
12061073
content: "I love you!".to_string(),
12071074
link: None,
@@ -1212,14 +1079,7 @@ mod tests {
12121079
let text = RichText {
12131080
href: None,
12141081
plain_text: "a > 5 but < 3 how?".to_string(),
1215-
annotations: Annotations {
1216-
bold: false,
1217-
italic: false,
1218-
strikethrough: false,
1219-
underline: false,
1220-
code: false,
1221-
color: Color::Default,
1222-
},
1082+
annotations: Default::default(),
12231083
ty: RichTextType::Text {
12241084
content: "a > 5 but < 3 how?".to_string(),
12251085
link: None,
@@ -1279,14 +1139,7 @@ mod tests {
12791139
let text = RichText {
12801140
href: None,
12811141
plain_text: "f(x)=y".to_string(),
1282-
annotations: Annotations {
1283-
bold: false,
1284-
italic: false,
1285-
strikethrough: false,
1286-
underline: false,
1287-
code: false,
1288-
color: Color::Default,
1289-
},
1142+
annotations: Default::default(),
12901143
ty: RichTextType::Equation {
12911144
expression: "f(x)=y".to_string(),
12921145
},

0 commit comments

Comments
 (0)