Skip to content

Commit 79f557f

Browse files
authored
style(quotes): standardise number of tabs for rust quotes (@nyxmeowmeow) (monkeytypegame#7001)
### Description changed the rust quotes to use one tab of indentation instead of two, a mixture of one or two, or even eight for some reason ### Checks - [ ] Adding quotes? - [ ] Make sure to include translations for the quotes in the description (or another comment) so we can verify their content. - [ ] Adding a language? - Make sure to follow the [languages documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/LANGUAGES.md) - [ ] Add language to `packages/schemas/src/languages.ts` - [ ] Add language to exactly one group in `frontend/src/ts/constants/languages.ts` - [ ] Add language json file to `frontend/static/languages` - [ ] Adding a theme? - Make sure to follow the [themes documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/THEMES.md) - [ ] Add theme to `packages/schemas/src/themes.ts` - [ ] Add theme to `frontend/src/ts/constants/themes.ts` - [ ] Add theme css file to `frontend/static/themes` - [ ] Add some screenshot of the theme, especially with different test settings (colorful, flip colors) to your pull request - [ ] Adding a layout? - [ ] Make sure to follow the [layouts documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/LAYOUTS.md) - [ ] Add layout to `packages/schemas/src/layouts.ts` - [ ] Add layout json file to `frontend/static/layouts` - [ ] Adding a font? - Make sure to follow the [themes documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/FONTS.md) - [ ] Add font file to `frontend/static/webfonts` - [ ] Add font to `packages/schemas/src/fonts.ts` - [ ] Add font to `frontend/src/ts/constants/fonts.ts` - [x] Check if any open issues are related to this PR; if so, be sure to tag them below. - [x] Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info) - [x] Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title.
1 parent 820ac71 commit 79f557f

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

frontend/static/quotes/code_rust.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
},
5252
{
5353
"id": 8,
54-
"length": 37,
54+
"length": 36,
5555
"source": "Iterate over list values - programming-idioms.org",
56-
"text": "for x in items {\n\t\tdo_something(x);\n}"
56+
"text": "for x in items {\n\tdo_something(x);\n}"
5757
},
5858
{
5959
"id": 9,
@@ -255,9 +255,9 @@
255255
},
256256
{
257257
"id": 43,
258-
"length": 145,
258+
"length": 143,
259259
"source": "Parallelize execution of 1000 independent tasks - programming-idioms.org",
260-
"text": "use std::thread;\nlet threads: Vec<_> = (0..1000).map(|i| {\n\t\tthread::spawn(move || f(i))\n}).collect();\nfor thread in threads {\n\t\tthread.join();\n}"
260+
"text": "use std::thread;\nlet threads: Vec<_> = (0..1000).map(|i| {\n\tthread::spawn(move || f(i))\n}).collect();\nfor thread in threads {\n\tthread.join();\n}"
261261
},
262262
{
263263
"id": 44,
@@ -297,9 +297,9 @@
297297
},
298298
{
299299
"id": 50,
300-
"length": 149,
300+
"length": 147,
301301
"source": "First-class function : compose - programming-idioms.org",
302-
"text": "fn compose<'a, A, B, C, G, F>(f: F, g: G) -> Box<dyn Fn(A) -> C + 'a>\n\t\twhere F: 'a + Fn(A) -> B, G: 'a + Fn(B) -> C\n{\n\t\tBox::new(move |x| g(f(x)))\n}"
302+
"text": "fn compose<'a, A, B, C, G, F>(f: F, g: G) -> Box<dyn Fn(A) -> C + 'a>\n\twhere F: 'a + Fn(A) -> B, G: 'a + Fn(B) -> C\n{\n\tBox::new(move |x| g(f(x)))\n}"
303303
},
304304
{
305305
"id": 51,
@@ -309,9 +309,9 @@
309309
},
310310
{
311311
"id": 52,
312-
"length": 149,
312+
"length": 147,
313313
"source": "First-class function : generic composition - programming-idioms.org",
314-
"text": "fn compose<'a, A, B, C, G, F>(f: F, g: G) -> Box<dyn Fn(A) -> C + 'a>\n\t\twhere F: 'a + Fn(A) -> B, G: 'a + Fn(B) -> C\n{\n\t\tBox::new(move |x| g(f(x)))\n}"
314+
"text": "fn compose<'a, A, B, C, G, F>(f: F, g: G) -> Box<dyn Fn(A) -> C + 'a>\n\twhere F: 'a + Fn(A) -> B, G: 'a + Fn(B) -> C\n{\n\tBox::new(move |x| g(f(x)))\n}"
315315
},
316316
{
317317
"id": 53,
@@ -459,9 +459,9 @@
459459
},
460460
{
461461
"id": 77,
462-
"length": 129,
462+
"length": 128,
463463
"source": "Launch 1000 parallel tasks and wait for completion - programming-idioms.org",
464-
"text": "use std::thread;\nlet threads: Vec<_> = (0..1000).map(|i| thread::spawn(move || f(i))).collect();\nfor t in threads {\n\t\tt.join();\n}"
464+
"text": "use std::thread;\nlet threads: Vec<_> = (0..1000).map(|i| thread::spawn(move || f(i))).collect();\nfor t in threads {\n\tt.join();\n}"
465465
},
466466
{
467467
"id": 78,
@@ -813,9 +813,9 @@
813813
},
814814
{
815815
"id": 136,
816-
"length": 108,
816+
"length": 107,
817817
"source": "Iterate over map entries, ordered by values - programming-idioms.org",
818-
"text": "use itertools::Itertools;\nfor (k, x) in mymap.iter().sorted_by_key(|x| x.1) {\n\t\tprintln!(\"[{},{}]\", k, x);\n}"
818+
"text": "use itertools::Itertools;\nfor (k, x) in mymap.iter().sorted_by_key(|x| x.1) {\n\tprintln!(\"[{},{}]\", k, x);\n}"
819819
},
820820
{
821821
"id": 137,
@@ -939,15 +939,15 @@
939939
},
940940
{
941941
"id": 157,
942-
"length": 497,
942+
"length": 482,
943943
"source": "Breadth-first traversing in a graph - programming-idioms.org",
944-
"text": "use std::rc::{Rc, Weak};\nuse std::cell::RefCell;\nstruct Vertex<V> {\n\t\tvalue: V,\n\t\tneighbours: Vec<Weak<RefCell<Vertex<V>>>>,\n}\n// ...\nfn bft(start: Rc<RefCell<Vertex<V>>>, f: impl Fn(&V)) {\n\t\tlet mut q = vec![start];\n\t\tlet mut i = 0;\n\t\twhile i < q.len() {\n\t\t\tlet v = Rc::clone(&q[i]);\n\t\t\ti += 1;\n\t\t\t(f)(&v.borrow().value);\n\t\t\tfor n in &v.borrow().neighbours {\n\t\t\t\tlet n = n.upgrade().expect(\"Invalid neighbour\");\n\t\t\t\tif q.iter().all(|v| v.as_ptr() != n.as_ptr()) {\n\t\t\t\t\tq.push(n);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n}"
944+
"text": "use std::rc::{Rc, Weak};\nuse std::cell::RefCell;\nstruct Vertex<V> {\n\tvalue: V,\n\tneighbours: Vec<Weak<RefCell<Vertex<V>>>>,\n}\n// ...\nfn bft(start: Rc<RefCell<Vertex<V>>>, f: impl Fn(&V)) {\n\tlet mut q = vec![start];\n\tlet mut i = 0;\n\twhile i < q.len() {\n\t\tlet v = Rc::clone(&q[i]);\n\t\ti += 1;\n\t\t(f)(&v.borrow().value);\n\t\tfor n in &v.borrow().neighbours {\n\t\t\tlet n = n.upgrade().expect(\"Invalid neighbour\");\n\t\t\tif q.iter().all(|v| v.as_ptr() != n.as_ptr()) {\n\t\t\t\tq.push(n);\n\t\t\t}\n\t\t}\n\t}\n}"
945945
},
946946
{
947947
"id": 158,
948-
"length": 465,
948+
"length": 450,
949949
"source": "Depth-first traversing in a graph - programming-idioms.org",
950-
"text": "use std::rc::{Rc, Weak};\nuse std::cell::RefCell;\nstruct Vertex<V> {\n\t\tvalue: V,\n\t\tneighbours: Vec<Weak<RefCell<Vertex<V>>>>,\n}\n// ...\nfn dft_helper(start: Rc<RefCell<Vertex<V>>>, f: &impl Fn(&V), s: &mut Vec<*const Vertex<V>>) {\n\t\ts.push(start.as_ptr());\n\t\t(f)(&start.borrow().value);\n\t\tfor n in &start.borrow().neighbours {\n\t\t\t\tlet n = n.upgrade().expect(\"Invalid neighbor\");\n\t\t\t\tif s.iter().all(|&p| p != n.as_ptr()) {\n\t\t\t\t\t\tSelf::dft_helper(n, f, s);\n\t\t\t\t}\n\t\t}\n}"
950+
"text": "use std::rc::{Rc, Weak};\nuse std::cell::RefCell;\nstruct Vertex<V> {\n\tvalue: V,\n\tneighbours: Vec<Weak<RefCell<Vertex<V>>>>,\n}\n// ...\nfn dft_helper(start: Rc<RefCell<Vertex<V>>>, f: &impl Fn(&V), s: &mut Vec<*const Vertex<V>>) {\n\ts.push(start.as_ptr());\n\t(f)(&start.borrow().value);\n\tfor n in &start.borrow().neighbours {\n\t\tlet n = n.upgrade().expect(\"Invalid neighbor\");\n\t\tif s.iter().all(|&p| p != n.as_ptr()) {\n\t\t\tSelf::dft_helper(n, f, s);\n\t\t}\n\t}\n}"
951951
},
952952
{
953953
"id": 159,
@@ -1005,9 +1005,9 @@
10051005
},
10061006
{
10071007
"id": 168,
1008-
"length": 141,
1008+
"length": 127,
10091009
"source": "Check if string contains only digits - programming-idioms.org",
1010-
"text": "let chars_are_numeric: Vec<bool> = s.chars()\n\t\t\t\t\t\t\t\t.map(|c|c.is_numeric())\n\t\t\t\t\t\t\t\t.collect();\nlet b = !chars_are_numeric.contains(&false);"
1010+
"text": "let chars_are_numeric: Vec<bool> = s.chars()\n\t.map(|c|c.is_numeric())\n\t.collect();\nlet b = !chars_are_numeric.contains(&false);"
10111011
},
10121012
{
10131013
"id": 169,
@@ -1347,9 +1347,9 @@
13471347
},
13481348
{
13491349
"id": 225,
1350-
"length": 63,
1350+
"length": 60,
13511351
"source": "Filter and transform list - programming-idioms.org",
1352-
"text": "let y = x.iter()\n\t\t.filter(P)\n\t\t.map(T)\n\t\t.collect::<Vec<_>>();"
1352+
"text": "let y = x.iter()\n\t.filter(P)\n\t.map(T)\n\t.collect::<Vec<_>>();"
13531353
},
13541354
{
13551355
"id": 226,
@@ -1377,9 +1377,9 @@
13771377
},
13781378
{
13791379
"id": 230,
1380-
"length": 129,
1380+
"length": 127,
13811381
"source": "Get a list of lines from a file - programming-idioms.org",
1382-
"text": "use std::io::prelude::*;\nuse std::io::BufReader;\nlet lines = BufReader::new(File::open(path)?)\n\t\t.lines()\n\t\t.collect::<Vec<_>>();"
1382+
"text": "use std::io::prelude::*;\nuse std::io::BufReader;\nlet lines = BufReader::new(File::open(path)?)\n\t.lines()\n\t.collect::<Vec<_>>();"
13831383
},
13841384
{
13851385
"id": 231,
@@ -1431,15 +1431,15 @@
14311431
},
14321432
{
14331433
"id": 239,
1434-
"length": 74,
1434+
"length": 73,
14351435
"source": "Formula with arrays - programming-idioms.org",
1436-
"text": "for i in range 0..a.len() {\n\t\ta[i] = e*(a[i] + b[i] + c[i] + d[i].cos())\n}"
1436+
"text": "for i in range 0..a.len() {\n\ta[i] = e*(a[i] + b[i] + c[i] + d[i].cos())\n}"
14371437
},
14381438
{
14391439
"id": 240,
1440-
"length": 131,
1440+
"length": 121,
14411441
"source": "Type with automatic deep deallocation - programming-idioms.org",
1442-
"text": "struct T {\n\t\ts: String,\n\t\tn: Vec<usize>,\n}\nfn main() {\n\t\tlet v = T {\n\t\t\t\ts: \"Hello, world!\".into(),\n\t\t\t\tn: vec![1,4,9,16,25]\n\t\t};\n}"
1442+
"text": "struct T {\n\ts: String,\n\tn: Vec<usize>,\n}\nfn main() {\n\tlet v = T {\n\ts: \"Hello, world!\".into(),\n\tn: vec![1,4,9,16,25]\n\t};\n}"
14431443
},
14441444
{
14451445
"id": 241,
@@ -1473,9 +1473,9 @@
14731473
},
14741474
{
14751475
"id": 246,
1476-
"length": 138,
1476+
"length": 136,
14771477
"source": "Pad a string on both sides - programming-idioms.org",
1478-
"text": "use std::iter;\nlet s2 = iter::repeat(c).take((m + 1) / 2).collect::<String>()\n\t\t+ &s\n\t\t+ &iter::repeat(c).take(m / 2).collect::<String>();"
1478+
"text": "use std::iter;\nlet s2 = iter::repeat(c).take((m + 1) / 2).collect::<String>()\n\t+ &s\n\t+ &iter::repeat(c).take(m / 2).collect::<String>();"
14791479
},
14801480
{
14811481
"id": 247,
@@ -1539,9 +1539,9 @@
15391539
},
15401540
{
15411541
"id": 257,
1542-
"length": 101,
1542+
"length": 99,
15431543
"source": "for else loop - programming-idioms.org",
1544-
"text": "if let None = items.iter().find(|&&item| item == \"rockstar programmer\") {\n\t\tprintln!(\"NotFound\");\n\t};"
1544+
"text": "if let None = items.iter().find(|&&item| item == \"rockstar programmer\") {\n\tprintln!(\"NotFound\");\n};"
15451545
},
15461546
{
15471547
"id": 258,

0 commit comments

Comments
 (0)