on master help sign in
Bump rust to 1.57, fix new lint failures
34f46e7Blaž Hrastnik
flake.lock+19−18
@@ -2,11 +2,11 @@
2 "nodes": {
2 "nodes": {
3 "devshell": {
3 "devshell": {
4 "locked": {
4 "locked": {
5− "lastModified": 1632436039,
5+ "lastModified": 1637575296,
6− "narHash": "sha256-OtITeVWcKXn1SpVEnImpTGH91FycCskGBPqmlxiykv4=",
6+ "narHash": "sha256-ZY8YR5u8aglZPe27+AJMnPTG6645WuavB+w0xmhTarw=",
7 "owner": "numtide",
7 "owner": "numtide",
8 "repo": "devshell",
8 "repo": "devshell",
9− "rev": "7a7a7aa0adebe5488e5abaec688fd9ae0f8ea9c6",
9+ "rev": "0e56ef21ba1a717169953122c7415fa6a8cd2618",
10 "type": "github"
10 "type": "github"
11 },
11 },
12 "original": {
12 "original": {
@@ -17,11 +17,11 @@
17 },
17 },
18 "flake-utils": {
18 "flake-utils": {
19 "locked": {
19 "locked": {
20− "lastModified": 1623875721,
20+ "lastModified": 1637014545,
21− "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
21+ "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
22 "owner": "numtide",
22 "owner": "numtide",
23 "repo": "flake-utils",
23 "repo": "flake-utils",
24− "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
24+ "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
25 "type": "github"
25 "type": "github"
26 },
26 },
27 "original": {
27 "original": {
@@ -41,11 +41,11 @@
41 ]
41 ]
42 },
42 },
43 "locked": {
43 "locked": {
44− "lastModified": 1634796585,
44+ "lastModified": 1638425401,
45− "narHash": "sha256-CW4yx6omk5qCXUIwXHp/sztA7u0SpyLq9NEACPnkiz8=",
45+ "narHash": "sha256-xc8ayvR3u90hSCMEy0zHHKav7lEgljAFXL4oIkWRp3M=",
46 "owner": "yusdacra",
46 "owner": "yusdacra",
47 "repo": "nix-cargo-integration",
47 "repo": "nix-cargo-integration",
48− "rev": "a84a2137a396f303978f1d48341e0390b0e16a8b",
48+ "rev": "1f8b511bb30f7d7b9051dfbb4784390bc0d48d37",
49 "type": "github"
49 "type": "github"
50 },
50 },
51 "original": {
51 "original": {
@@ -56,11 +56,11 @@
56 },
56 },
57 "nixpkgs": {
57 "nixpkgs": {
58 "locked": {
58 "locked": {
59− "lastModified": 1634782485,
59+ "lastModified": 1638376152,
60− "narHash": "sha256-psfh4OQSokGXG0lpq3zKFbhOo3QfoeudRcaUnwMRkQo=",
60+ "narHash": "sha256-ucgLpVqhFnClH7YRUHBHnmiOd82RZdFR3XJt36ks5fE=",
61 "owner": "nixos",
61 "owner": "nixos",
62 "repo": "nixpkgs",
62 "repo": "nixpkgs",
63− "rev": "34ad3ffe08adfca17fcb4e4a47bb5f3b113687be",
63+ "rev": "6daa4a5c045d40e6eae60a3b6e427e8700f1c07f",
64 "type": "github"
64 "type": "github"
65 },
65 },
66 "original": {
66 "original": {
@@ -72,15 +72,16 @@
72 },
72 },
73 "nixpkgs_2": {
73 "nixpkgs_2": {
74 "locked": {
74 "locked": {
75− "lastModified": 1628186154,
75+ "lastModified": 1637453606,
76− "narHash": "sha256-r2d0wvywFnL9z4iptztdFMhaUIAaGzrSs7kSok0PgmE=",
76+ "narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=",
77 "owner": "NixOS",
77 "owner": "NixOS",
78 "repo": "nixpkgs",
78 "repo": "nixpkgs",
79− "rev": "06552b72346632b6943c8032e57e702ea12413bf",
79+ "rev": "8afc4e543663ca0a6a4f496262cd05233737e732",
80 "type": "github"
80 "type": "github"
81 },
81 },
82 "original": {
82 "original": {
83 "owner": "NixOS",
83 "owner": "NixOS",
84+ "ref": "nixpkgs-unstable",
84 "repo": "nixpkgs",
85 "repo": "nixpkgs",
85 "type": "github"
86 "type": "github"
86 }
87 }
@@ -98,11 +99,11 @@
98 "nixpkgs": "nixpkgs_2"
99 "nixpkgs": "nixpkgs_2"
99 },
100 },
100 "locked": {
101 "locked": {
101− "lastModified": 1634869268,
102+ "lastModified": 1638497756,
102− "narHash": "sha256-RVAcEFlFU3877Mm4q/nbXGEYTDg/wQNhzmXGMTV6wBs=",
103+ "narHash": "sha256-zKOvMKqGp71ZBnR+hBlPcv4TwNN82COW9EF+6ygrFs8=",
103 "owner": "oxalica",
104 "owner": "oxalica",
104 "repo": "rust-overlay",
105 "repo": "rust-overlay",
105− "rev": "c02c2d86354327317546501af001886fbb53d374",
106+ "rev": "783722a22ee5d762ac5c1c7b418b57b3010c827a",
106 "type": "github"
107 "type": "github"
107 },
108 },
108 "original": {
109 "original": {
helix-term/src/commands.rs+25−25
@@ -2256,7 +2256,7 @@ mod cmd {
2256 args: &[&str],
2256 args: &[&str],
2257 event: PromptEvent,
2257 event: PromptEvent,
2258 ) -> anyhow::Result<()> {
2258 ) -> anyhow::Result<()> {
2259− quit_all_impl(&mut cx.editor, args, event, false)
2259+ quit_all_impl(cx.editor, args, event, false)
2260 }
2260 }
2261
2261
2262 fn force_quit_all(
2262 fn force_quit_all(
@@ -2264,7 +2264,7 @@ mod cmd {
2264 args: &[&str],
2264 args: &[&str],
2265 event: PromptEvent,
2265 event: PromptEvent,
2266 ) -> anyhow::Result<()> {
2266 ) -> anyhow::Result<()> {
2267− quit_all_impl(&mut cx.editor, args, event, true)
2267+ quit_all_impl(cx.editor, args, event, true)
2268 }
2268 }
2269
2269
2270 fn cquit(
2270 fn cquit(
@@ -2300,7 +2300,7 @@ mod cmd {
2300 _args: &[&str],
2300 _args: &[&str],
2301 _event: PromptEvent,
2301 _event: PromptEvent,
2302 ) -> anyhow::Result<()> {
2302 ) -> anyhow::Result<()> {
2303− yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Clipboard)
2303+ yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Clipboard)
2304 }
2304 }
2305
2305
2306 fn yank_joined_to_clipboard(
2306 fn yank_joined_to_clipboard(
@@ -2313,7 +2313,7 @@ mod cmd {
2313 .first()
2313 .first()
2314 .copied()
2314 .copied()
2315 .unwrap_or_else(|| doc.line_ending.as_str());
2315 .unwrap_or_else(|| doc.line_ending.as_str());
2316− yank_joined_to_clipboard_impl(&mut cx.editor, separator, ClipboardType::Clipboard)
2316+ yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Clipboard)
2317 }
2317 }
2318
2318
2319 fn yank_main_selection_to_primary_clipboard(
2319 fn yank_main_selection_to_primary_clipboard(
@@ -2321,7 +2321,7 @@ mod cmd {
2321 _args: &[&str],
2321 _args: &[&str],
2322 _event: PromptEvent,
2322 _event: PromptEvent,
2323 ) -> anyhow::Result<()> {
2323 ) -> anyhow::Result<()> {
2324− yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Selection)
2324+ yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Selection)
2325 }
2325 }
2326
2326
2327 fn yank_joined_to_primary_clipboard(
2327 fn yank_joined_to_primary_clipboard(
@@ -2334,7 +2334,7 @@ mod cmd {
2334 .first()
2334 .first()
2335 .copied()
2335 .copied()
2336 .unwrap_or_else(|| doc.line_ending.as_str());
2336 .unwrap_or_else(|| doc.line_ending.as_str());
2337− yank_joined_to_clipboard_impl(&mut cx.editor, separator, ClipboardType::Selection)
2337+ yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Selection)
2338 }
2338 }
2339
2339
2340 fn paste_clipboard_after(
2340 fn paste_clipboard_after(
@@ -2342,7 +2342,7 @@ mod cmd {
2342 _args: &[&str],
2342 _args: &[&str],
2343 _event: PromptEvent,
2343 _event: PromptEvent,
2344 ) -> anyhow::Result<()> {
2344 ) -> anyhow::Result<()> {
2345− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Clipboard)
2345+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Clipboard)
2346 }
2346 }
2347
2347
2348 fn paste_clipboard_before(
2348 fn paste_clipboard_before(
@@ -2350,7 +2350,7 @@ mod cmd {
2350 _args: &[&str],
2350 _args: &[&str],
2351 _event: PromptEvent,
2351 _event: PromptEvent,
2352 ) -> anyhow::Result<()> {
2352 ) -> anyhow::Result<()> {
2353− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Clipboard)
2353+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Clipboard)
2354 }
2354 }
2355
2355
2356 fn paste_primary_clipboard_after(
2356 fn paste_primary_clipboard_after(
@@ -2358,7 +2358,7 @@ mod cmd {
2358 _args: &[&str],
2358 _args: &[&str],
2359 _event: PromptEvent,
2359 _event: PromptEvent,
2360 ) -> anyhow::Result<()> {
2360 ) -> anyhow::Result<()> {
2361− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Selection)
2361+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Selection)
2362 }
2362 }
2363
2363
2364 fn paste_primary_clipboard_before(
2364 fn paste_primary_clipboard_before(
@@ -2366,7 +2366,7 @@ mod cmd {
2366 _args: &[&str],
2366 _args: &[&str],
2367 _event: PromptEvent,
2367 _event: PromptEvent,
2368 ) -> anyhow::Result<()> {
2368 ) -> anyhow::Result<()> {
2369− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Selection)
2369+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Selection)
2370 }
2370 }
2371
2371
2372 fn replace_selections_with_clipboard_impl(
2372 fn replace_selections_with_clipboard_impl(
@@ -2544,7 +2544,7 @@ mod cmd {
2544
2544
2545 let line = args[0].parse::<usize>()?;
2545 let line = args[0].parse::<usize>()?;
2546
2546
2547− goto_line_impl(&mut cx.editor, NonZeroUsize::new(line));
2547+ goto_line_impl(cx.editor, NonZeroUsize::new(line));
2548
2548
2549 let (view, doc) = current!(cx.editor);
2549 let (view, doc) = current!(cx.editor);
2550
2550
@@ -3545,7 +3545,7 @@ fn push_jump(editor: &mut Editor) {
3545}
3545}
3546
3546
3547fn goto_line(cx: &mut Context) {
3547fn goto_line(cx: &mut Context) {
3548− goto_line_impl(&mut cx.editor, cx.count)
3548+ goto_line_impl(cx.editor, cx.count)
3549}
3549}
3550
3550
3551fn goto_line_impl(editor: &mut Editor, count: Option<NonZeroUsize>) {
3551fn goto_line_impl(editor: &mut Editor, count: Option<NonZeroUsize>) {
@@ -4445,7 +4445,7 @@ fn yank_joined_to_clipboard_impl(
4445fn yank_joined_to_clipboard(cx: &mut Context) {
4445fn yank_joined_to_clipboard(cx: &mut Context) {
4446 let line_ending = doc!(cx.editor).line_ending;
4446 let line_ending = doc!(cx.editor).line_ending;
4447 let _ = yank_joined_to_clipboard_impl(
4447 let _ = yank_joined_to_clipboard_impl(
4448− &mut cx.editor,
4448+ cx.editor,
4449 line_ending.as_str(),
4449 line_ending.as_str(),
4450 ClipboardType::Clipboard,
4450 ClipboardType::Clipboard,
4451 );
4451 );
@@ -4473,20 +4473,20 @@ fn yank_main_selection_to_clipboard_impl(
4473}
4473}
4474
4474
4475fn yank_main_selection_to_clipboard(cx: &mut Context) {
4475fn yank_main_selection_to_clipboard(cx: &mut Context) {
4476− let _ = yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Clipboard);
4476+ let _ = yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Clipboard);
4477}
4477}
4478
4478
4479fn yank_joined_to_primary_clipboard(cx: &mut Context) {
4479fn yank_joined_to_primary_clipboard(cx: &mut Context) {
4480 let line_ending = doc!(cx.editor).line_ending;
4480 let line_ending = doc!(cx.editor).line_ending;
4481 let _ = yank_joined_to_clipboard_impl(
4481 let _ = yank_joined_to_clipboard_impl(
4482− &mut cx.editor,
4482+ cx.editor,
4483 line_ending.as_str(),
4483 line_ending.as_str(),
4484 ClipboardType::Selection,
4484 ClipboardType::Selection,
4485 );
4485 );
4486}
4486}
4487
4487
4488fn yank_main_selection_to_primary_clipboard(cx: &mut Context) {
4488fn yank_main_selection_to_primary_clipboard(cx: &mut Context) {
4489− let _ = yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Selection);
4489+ let _ = yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Selection);
4490 exit_select_mode(cx);
4490 exit_select_mode(cx);
4491}
4491}
4492
4492
@@ -4569,19 +4569,19 @@ fn paste_clipboard_impl(
4569}
4569}
4570
4570
4571fn paste_clipboard_after(cx: &mut Context) {
4571fn paste_clipboard_after(cx: &mut Context) {
4572− let _ = paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Clipboard);
4572+ let _ = paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Clipboard);
4573}
4573}
4574
4574
4575fn paste_clipboard_before(cx: &mut Context) {
4575fn paste_clipboard_before(cx: &mut Context) {
4576− let _ = paste_clipboard_impl(&mut cx.editor, Paste::Before, ClipboardType::Clipboard);
4576+ let _ = paste_clipboard_impl(cx.editor, Paste::Before, ClipboardType::Clipboard);
4577}
4577}
4578
4578
4579fn paste_primary_clipboard_after(cx: &mut Context) {
4579fn paste_primary_clipboard_after(cx: &mut Context) {
4580− let _ = paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Selection);
4580+ let _ = paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Selection);
4581}
4581}
4582
4582
4583fn paste_primary_clipboard_before(cx: &mut Context) {
4583fn paste_primary_clipboard_before(cx: &mut Context) {
4584− let _ = paste_clipboard_impl(&mut cx.editor, Paste::Before, ClipboardType::Selection);
4584+ let _ = paste_clipboard_impl(cx.editor, Paste::Before, ClipboardType::Selection);
4585}
4585}
4586
4586
4587fn replace_with_yanked(cx: &mut Context) {
4587fn replace_with_yanked(cx: &mut Context) {
@@ -4638,11 +4638,11 @@ fn replace_selections_with_clipboard_impl(
4638}
4638}
4639
4639
4640fn replace_selections_with_clipboard(cx: &mut Context) {
4640fn replace_selections_with_clipboard(cx: &mut Context) {
4641− let _ = replace_selections_with_clipboard_impl(&mut cx.editor, ClipboardType::Clipboard);
4641+ let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Clipboard);
4642}
4642}
4643
4643
4644fn replace_selections_with_primary_clipboard(cx: &mut Context) {
4644fn replace_selections_with_primary_clipboard(cx: &mut Context) {
4645− let _ = replace_selections_with_clipboard_impl(&mut cx.editor, ClipboardType::Selection);
4645+ let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Selection);
4646}
4646}
4647
4647
4648fn paste_after(cx: &mut Context) {
4648fn paste_after(cx: &mut Context) {
@@ -5157,7 +5157,7 @@ fn expand_selection(cx: &mut Context) {
5157 doc.set_selection(view.id, selection);
5157 doc.set_selection(view.id, selection);
5158 }
5158 }
5159 };
5159 };
5160− motion(&mut cx.editor);
5160+ motion(cx.editor);
5161 cx.editor.last_motion = Some(Motion(Box::new(motion)));
5161 cx.editor.last_motion = Some(Motion(Box::new(motion)));
5162}
5162}
5163
5163
@@ -5389,7 +5389,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
5389 });
5389 });
5390 doc.set_selection(view.id, selection);
5390 doc.set_selection(view.id, selection);
5391 };
5391 };
5392− textobject(&mut cx.editor);
5392+ textobject(cx.editor);
5393 cx.editor.last_motion = Some(Motion(Box::new(textobject)));
5393 cx.editor.last_motion = Some(Motion(Box::new(textobject)));
5394 }
5394 }
5395 })
5395 })
@@ -5719,7 +5719,7 @@ fn rename_symbol(cx: &mut Context) {
5719 let task = language_server.rename_symbol(doc.identifier(), pos, input.to_string());
5719 let task = language_server.rename_symbol(doc.identifier(), pos, input.to_string());
5720 let edits = block_on(task).unwrap_or_default();
5720 let edits = block_on(task).unwrap_or_default();
5721 log::debug!("Edits from LSP: {:?}", edits);
5721 log::debug!("Edits from LSP: {:?}", edits);
5722− apply_workspace_edit(&mut cx.editor, offset_encoding, &edits);
5722+ apply_workspace_edit(cx.editor, offset_encoding, &edits);
5723 },
5723 },
5724 );
5724 );
5725 cx.push_layer(Box::new(prompt));
5725 cx.push_layer(Box::new(prompt));
helix-term/src/ui/editor.rs+1−1
@@ -922,7 +922,7 @@ impl EditorView {
922impl Component for EditorView {
922impl Component for EditorView {
923 fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
923 fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
924 let mut cxt = commands::Context {
924 let mut cxt = commands::Context {
925− editor: &mut cx.editor,
925+ editor: cx.editor,
926 count: None,
926 count: None,
927 register: None,
927 register: None,
928 callback: None,
928 callback: None,
helix-term/src/ui/picker.rs+5−5
@@ -46,7 +46,7 @@ pub struct FilePicker<T> {
46}
46}
47
47
48pub enum CachedPreview {
48pub enum CachedPreview {
49− Document(Document),
49+ Document(Box<Document>),
50 Binary,
50 Binary,
51 LargeFile,
51 LargeFile,
52 NotFound,
52 NotFound,
@@ -140,7 +140,7 @@ impl<T> FilePicker<T> {
140 _ => {
140 _ => {
141 // TODO: enable syntax highlighting; blocked by async rendering
141 // TODO: enable syntax highlighting; blocked by async rendering
142 Document::open(path, None, Some(&editor.theme), None)
142 Document::open(path, None, Some(&editor.theme), None)
143− .map(CachedPreview::Document)
143+ .map(|doc| CachedPreview::Document(Box::new(doc)))
144 .unwrap_or(CachedPreview::NotFound)
144 .unwrap_or(CachedPreview::NotFound)
145 }
145 }
146 },
146 },
@@ -421,19 +421,19 @@ impl<T: 'static> Component for Picker<T> {
421 }
421 }
422 key!(Enter) => {
422 key!(Enter) => {
423 if let Some(option) = self.selection() {
423 if let Some(option) = self.selection() {
424− (self.callback_fn)(&mut cx.editor, option, Action::Replace);
424+ (self.callback_fn)(cx.editor, option, Action::Replace);
425 }
425 }
426 return close_fn;
426 return close_fn;
427 }
427 }
428 ctrl!('s') => {
428 ctrl!('s') => {
429 if let Some(option) = self.selection() {
429 if let Some(option) = self.selection() {
430− (self.callback_fn)(&mut cx.editor, option, Action::HorizontalSplit);
430+ (self.callback_fn)(cx.editor, option, Action::HorizontalSplit);
431 }
431 }
432 return close_fn;
432 return close_fn;
433 }
433 }
434 ctrl!('v') => {
434 ctrl!('v') => {
435 if let Some(option) = self.selection() {
435 if let Some(option) = self.selection() {
436− (self.callback_fn)(&mut cx.editor, option, Action::VerticalSplit);
436+ (self.callback_fn)(cx.editor, option, Action::VerticalSplit);
437 }
437 }
438 return close_fn;
438 return close_fn;
439 }
439 }
helix-tui/src/buffer.rs+1−10
@@ -102,7 +102,7 @@ impl Default for Cell {
102/// buf.get_mut(5, 0).set_char('x');
102/// buf.get_mut(5, 0).set_char('x');
103/// assert_eq!(buf.get(5, 0).symbol, "x");
103/// assert_eq!(buf.get(5, 0).symbol, "x");
104/// ```
104/// ```
105−#[derive(Debug, Clone, PartialEq)]
105+#[derive(Debug, Default, Clone, PartialEq)]
106pub struct Buffer {
106pub struct Buffer {
107 /// The area represented by this buffer
107 /// The area represented by this buffer
108 pub area: Rect,
108 pub area: Rect,
@@ -111,15 +111,6 @@ pub struct Buffer {
111 pub content: Vec<Cell>,
111 pub content: Vec<Cell>,
112}
112}
113
113
114−impl Default for Buffer {
115− fn default() -> Buffer {
116− Buffer {
117− area: Default::default(),
118− content: Vec::new(),
119− }
120− }
121−}
122−
123impl Buffer {
114impl Buffer {
124 /// Returns a Buffer with all cells set to the default one
115 /// Returns a Buffer with all cells set to the default one
125 pub fn empty(area: Rect) -> Buffer {
116 pub fn empty(area: Rect) -> Buffer {
helix-tui/src/text.rs+2−14
@@ -195,15 +195,9 @@ impl<'a> From<&'a str> for Span<'a> {
195}
195}
196
196
197/// A string composed of clusters of graphemes, each with their own style.
197/// A string composed of clusters of graphemes, each with their own style.
198−#[derive(Debug, Clone, PartialEq)]
198+#[derive(Debug, Default, Clone, PartialEq)]
199pub struct Spans<'a>(pub Vec<Span<'a>>);
199pub struct Spans<'a>(pub Vec<Span<'a>>);
200
200
201−impl<'a> Default for Spans<'a> {
202− fn default() -> Spans<'a> {
203− Spans(Vec::new())
204− }
205−}
206−
207impl<'a> Spans<'a> {
201impl<'a> Spans<'a> {
208 /// Returns the width of the underlying string.
202 /// Returns the width of the underlying string.
209 ///
203 ///
@@ -280,17 +274,11 @@ impl<'a> From<Spans<'a>> for String {
280/// text.extend(Text::styled("Some more lines\nnow with more style!", style));
274/// text.extend(Text::styled("Some more lines\nnow with more style!", style));
281/// assert_eq!(6, text.height());
275/// assert_eq!(6, text.height());
282/// ```
276/// ```
283−#[derive(Debug, Clone, PartialEq)]
277+#[derive(Debug, Default, Clone, PartialEq)]
284pub struct Text<'a> {
278pub struct Text<'a> {
285 pub lines: Vec<Spans<'a>>,
279 pub lines: Vec<Spans<'a>>,
286}
280}
287
281
288−impl<'a> Default for Text<'a> {
289− fn default() -> Text<'a> {
290− Text { lines: Vec::new() }
291− }
292−}
293−
294impl<'a> Text<'a> {
282impl<'a> Text<'a> {
295 /// Create some text (potentially multiple lines) with no style.
283 /// Create some text (potentially multiple lines) with no style.
296 ///
284 ///
helix-tui/src/widgets/table.rs+1−10
@@ -363,21 +363,12 @@ impl<'a> Table<'a> {
363 }
363 }
364}
364}
365
365
366−#[derive(Debug, Clone)]
366+#[derive(Debug, Default, Clone)]
367pub struct TableState {
367pub struct TableState {
368 pub offset: usize,
368 pub offset: usize,
369 pub selected: Option<usize>,
369 pub selected: Option<usize>,
370}
370}
371
371
372−impl Default for TableState {
373− fn default() -> TableState {
374− TableState {
375− offset: 0,
376− selected: None,
377− }
378− }
379−}
380−
381impl TableState {
372impl TableState {
382 pub fn selected(&self) -> Option<usize> {
373 pub fn selected(&self) -> Option<usize> {
383 self.selected
374 self.selected
helix-view/src/graphics.rs+1−12
@@ -25,7 +25,7 @@ pub struct Margin {
25
25
26/// A simple rectangle used in the computation of the layout and to give widgets an hint about the
26/// A simple rectangle used in the computation of the layout and to give widgets an hint about the
27/// area they are supposed to render to. (x, y) = (0, 0) is at the top left corner of the screen.
27/// area they are supposed to render to. (x, y) = (0, 0) is at the top left corner of the screen.
28−#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
28+#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq)]
29pub struct Rect {
29pub struct Rect {
30 pub x: u16,
30 pub x: u16,
31 pub y: u16,
31 pub y: u16,
@@ -33,17 +33,6 @@ pub struct Rect {
33 pub height: u16,
33 pub height: u16,
34}
34}
35
35
36−impl Default for Rect {
37− fn default() -> Rect {
38− Rect {
39− x: 0,
40− y: 0,
41− width: 0,
42− height: 0,
43− }
44− }
45−}
46−
47impl Rect {
36impl Rect {
48 /// Creates a new rect, with width and height limited to keep the area under max u16.
37 /// Creates a new rect, with width and height limited to keep the area under max u16.
49 /// If clipped, aspect ratio will be preserved.
38 /// If clipped, aspect ratio will be preserved.