Skip to content
This repository was archived by the owner on Oct 10, 2019. It is now read-only.

Commit 20851f4

Browse files
committed
Add rustfmt.toml
Signed-off-by: Sascha Grunert <[email protected]>
1 parent a54c756 commit 20851f4

File tree

4 files changed

+80
-43
lines changed

4 files changed

+80
-43
lines changed

.rustfmt.toml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
max_width = 100
2+
hard_tabs = false
3+
tab_spaces = 4
4+
newline_style = "Auto"
5+
use_small_heuristics = "Default"
6+
indent_style = "Block"
7+
wrap_comments = true
8+
format_code_in_doc_comments = true
9+
comment_width = 80
10+
normalize_comments = true
11+
normalize_doc_attributes = true
12+
license_template_path = ""
13+
format_strings = true
14+
format_macro_matchers = true
15+
format_macro_bodies = true
16+
empty_item_single_line = true
17+
struct_lit_single_line = true
18+
fn_single_line = true
19+
where_single_line = true
20+
imports_indent = "Block"
21+
imports_layout = "Mixed"
22+
merge_imports = false
23+
reorder_imports = true
24+
reorder_modules = true
25+
reorder_impl_items = true
26+
type_punctuation_density = "Wide"
27+
space_before_colon = false
28+
space_after_colon = true
29+
spaces_around_ranges = false
30+
binop_separator = "Front"
31+
remove_nested_parens = true
32+
combine_control_expr = true
33+
overflow_delimited_expr = false
34+
struct_field_align_threshold = 0
35+
enum_discrim_align_threshold = 0
36+
match_arm_blocks = true
37+
force_multiline_blocks = false
38+
fn_args_layout = "Tall"
39+
brace_style = "SameLineWhere"
40+
control_brace_style = "AlwaysSameLine"
41+
trailing_semicolon = true
42+
trailing_comma = "Vertical"
43+
match_block_trailing_comma = false
44+
blank_lines_upper_bound = 1
45+
blank_lines_lower_bound = 0
46+
edition = "2018"
47+
version = "One"
48+
inline_attribute_width = 0
49+
merge_derives = true
50+
use_try_shorthand = true
51+
use_field_init_shorthand = true
52+
force_explicit_abi = true
53+
condense_wildcard_suffixes = false
54+
color = "Auto"
55+
required_version = "1.4.4"
56+
unstable_features = true
57+
disable_all_formatting = false
58+
skip_children = false
59+
hide_parse_errors = false
60+
error_on_line_overflow = false
61+
error_on_unformatted = false
62+
report_todo = "Never"
63+
report_fixme = "Never"
64+
ignore = []
65+
emit_mode = "Files"
66+
make_backup = false

examples/history_state.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@ use std::{convert::Into, fmt, str::FromStr};
66
use log::info;
77
use serde::{Deserialize, Serialize};
88
use smart_default::SmartDefault;
9-
use stdweb::{
10-
__js_serializable_boilerplate, js_deserializable, js_serializable,
11-
};
9+
use stdweb::{__js_serializable_boilerplate, js_deserializable, js_serializable};
1210
use web_logger;
13-
use yew::{
14-
html, Bridge, Bridged, Component, ComponentLink, Html, Renderable,
15-
ShouldRender,
16-
};
11+
use yew::{html, Bridge, Bridged, Component, ComponentLink, Html, Renderable, ShouldRender};
1712
use yew_router::{Route, RouterAgent};
1813

1914
#[derive(SmartDefault, Debug, Clone, PartialEq, Serialize, Deserialize)]
@@ -48,17 +43,11 @@ impl fmt::Display for RouterTarget {
4843
match self {
4944
RouterTarget::Home => "home".into(),
5045
RouterTarget::Feed => "feed".into(),
51-
RouterTarget::Profile { user_id } => {
52-
format!("profile/{}", user_id)
53-
}
54-
RouterTarget::Foo { name, id } => {
55-
format!("foo/{}/{}", name, id)
56-
}
46+
RouterTarget::Profile { user_id } => format!("profile/{}", user_id),
47+
RouterTarget::Foo { name, id } => format!("foo/{}/{}", name, id),
5748
RouterTarget::Post(i) => format!("post/{}", i),
5849
RouterTarget::Bar(s, i) => format!("bar/{}/{}", s, i),
59-
RouterTarget::Settings(sub_route) => {
60-
format!("settings/{}", sub_route)
61-
}
50+
RouterTarget::Settings(sub_route) => format!("settings/{}", sub_route),
6251
},
6352
)
6453
}
@@ -93,12 +82,8 @@ impl FromStr for RouterTarget {
9382
id: parse(id)?,
9483
},
9584
["post", id] => RouterTarget::Post(parse(id)?),
96-
["bar", name, id] => {
97-
RouterTarget::Bar(name.to_string(), parse(id)?)
98-
}
99-
["settings", sub_route] => {
100-
RouterTarget::Settings(parse(&sub_route.join("/"))?)
101-
}
85+
["bar", name, id] => RouterTarget::Bar(name.to_string(), parse(id)?),
86+
["settings", sub_route] => RouterTarget::Settings(parse(&sub_route.join("/"))?),
10287
_ => Err(())?,
10388
})
10489
}
@@ -196,8 +181,7 @@ impl Component for RootComponent {
196181
fn create(_: Self::Properties, mut link: ComponentLink<Self>) -> Self {
197182
// Connect to the router agent using Yew's bridge method for workers
198183
// Send back the method we will be using to route the user
199-
let mut router_agent =
200-
RouterAgent::bridge(link.send_back(PageActions::Route));
184+
let mut router_agent = RouterAgent::bridge(link.send_back(PageActions::Route));
201185
router_agent.send(yew_router::Request::GetCurrentRoute);
202186

203187
RootComponent {

examples/minimal.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#![recursion_limit = "256"]
22

3-
use yew::{
4-
html, Bridge, Bridged, Component, ComponentLink, Html, Renderable,
5-
ShouldRender,
6-
};
3+
use yew::{html, Bridge, Bridged, Component, ComponentLink, Html, Renderable, ShouldRender};
74
use yew_router::{routes, Route, RouterAgent};
85

96
// Define application routes via the macro
@@ -40,8 +37,7 @@ impl Component for RootComponent {
4037
fn create(_: Self::Properties, mut link: ComponentLink<Self>) -> Self {
4138
// Connect to the router agent using Yew's bridge method for workers
4239
// Send back the method we will be using to route the user
43-
let router_agent =
44-
RouterAgent::bridge(link.send_back(PageActions::Route));
40+
let router_agent = RouterAgent::bridge(link.send_back(PageActions::Route));
4541

4642
RootComponent {
4743
child_component: RouterTarget::Login,

src/router.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ use std::{collections::HashSet, fmt::Debug, marker::PhantomData};
44
use stdweb::{
55
js,
66
unstable::TryFrom,
7-
web::{
8-
event::PopStateEvent, window, EventListenerHandle, History,
9-
IEventTarget, Location,
10-
},
7+
web::{event::PopStateEvent, window, EventListenerHandle, History, IEventTarget, Location},
118
JsSerialize, Value,
129
};
1310
use yew::{callback::Callback, prelude::worker::*};
@@ -45,9 +42,7 @@ where
4542
/// of its stack when the forward or back buttons are pressed.
4643
pub fn register_callback(&mut self, callback: Callback<()>) {
4744
self.event_listener =
48-
Some(window().add_event_listener(move |_event: PopStateEvent| {
49-
callback.emit(())
50-
}));
45+
Some(window().add_event_listener(move |_event: PopStateEvent| callback.emit(())));
5146
}
5247

5348
/// Sets the browser's url bar to contain the provided route, and creates a
@@ -145,8 +140,7 @@ where
145140
pub fn current_route(route_service: &RouterService<T>) -> Fallible<Self> {
146141
// guaranteed to always start with a '/'
147142
let path = route_service.get_path()?;
148-
let mut path_segments: Vec<String> =
149-
path.split('/').map(String::from).collect();
143+
let mut path_segments: Vec<String> = path.split('/').map(String::from).collect();
150144
// remove empty string that is split from the first '/'
151145
path_segments.remove(0);
152146

@@ -194,10 +188,7 @@ pub enum Request<T> {
194188
GetCurrentRoute,
195189
}
196190

197-
impl<T> Transferable for Request<T> where
198-
for<'de> T: Serialize + Deserialize<'de>
199-
{
200-
}
191+
impl<T> Transferable for Request<T> where for<'de> T: Serialize + Deserialize<'de> {}
201192

202193
/// The RouterAgent worker holds on to the RouterService singleton and mediates
203194
/// access to it.

0 commit comments

Comments
 (0)