1
1
use std:: borrow:: Cow ;
2
2
3
- #[ cfg( not( target_os = "wasi" ) ) ]
4
3
use crate :: browser:: BrowserHistory ;
5
- #[ cfg( not( target_os = "wasi" ) ) ]
6
4
use crate :: hash:: HashHistory ;
7
5
use crate :: history:: History ;
8
6
use crate :: listener:: HistoryListener ;
@@ -15,10 +13,8 @@ use crate::{error::HistoryResult, query::ToQuery};
15
13
#[ derive( Clone , PartialEq , Debug ) ]
16
14
pub enum AnyHistory {
17
15
/// A Browser History.
18
- #[ cfg( not( target_os = "wasi" ) ) ]
19
16
Browser ( BrowserHistory ) ,
20
17
/// A Hash History
21
- #[ cfg( not( target_os = "wasi" ) ) ]
22
18
Hash ( HashHistory ) ,
23
19
/// A Memory History
24
20
Memory ( MemoryHistory ) ,
@@ -27,39 +23,35 @@ pub enum AnyHistory {
27
23
impl History for AnyHistory {
28
24
fn len ( & self ) -> usize {
29
25
match self {
30
- #[ cfg( not( target_os = "wasi" ) ) ]
31
26
Self :: Browser ( m) => m. len ( ) ,
32
- # [ cfg ( not ( target_os = "wasi" ) ) ]
27
+
33
28
Self :: Hash ( m) => m. len ( ) ,
34
29
Self :: Memory ( m) => m. len ( ) ,
35
30
}
36
31
}
37
32
38
33
fn go ( & self , delta : isize ) {
39
34
match self {
40
- #[ cfg( not( target_os = "wasi" ) ) ]
41
35
Self :: Browser ( m) => m. go ( delta) ,
42
- # [ cfg ( not ( target_os = "wasi" ) ) ]
36
+
43
37
Self :: Hash ( m) => m. go ( delta) ,
44
38
Self :: Memory ( m) => m. go ( delta) ,
45
39
}
46
40
}
47
41
48
42
fn push < ' a > ( & self , route : impl Into < Cow < ' a , str > > ) {
49
43
match self {
50
- #[ cfg( not( target_os = "wasi" ) ) ]
51
44
Self :: Browser ( m) => m. push ( route) ,
52
- # [ cfg ( not ( target_os = "wasi" ) ) ]
45
+
53
46
Self :: Hash ( m) => m. push ( route) ,
54
47
Self :: Memory ( m) => m. push ( route) ,
55
48
}
56
49
}
57
50
58
51
fn replace < ' a > ( & self , route : impl Into < Cow < ' a , str > > ) {
59
52
match self {
60
- #[ cfg( not( target_os = "wasi" ) ) ]
61
53
Self :: Browser ( m) => m. replace ( route) ,
62
- # [ cfg ( not ( target_os = "wasi" ) ) ]
54
+
63
55
Self :: Hash ( m) => m. replace ( route) ,
64
56
Self :: Memory ( m) => m. replace ( route) ,
65
57
}
@@ -70,9 +62,8 @@ impl History for AnyHistory {
70
62
T : ' static ,
71
63
{
72
64
match self {
73
- #[ cfg( not( target_os = "wasi" ) ) ]
74
65
Self :: Browser ( m) => m. push_with_state ( route, state) ,
75
- # [ cfg ( not ( target_os = "wasi" ) ) ]
66
+
76
67
Self :: Hash ( m) => m. push_with_state ( route, state) ,
77
68
Self :: Memory ( m) => m. push_with_state ( route, state) ,
78
69
}
@@ -83,9 +74,8 @@ impl History for AnyHistory {
83
74
T : ' static ,
84
75
{
85
76
match self {
86
- #[ cfg( not( target_os = "wasi" ) ) ]
87
77
Self :: Browser ( m) => m. replace_with_state ( route, state) ,
88
- # [ cfg ( not ( target_os = "wasi" ) ) ]
78
+
89
79
Self :: Hash ( m) => m. replace_with_state ( route, state) ,
90
80
Self :: Memory ( m) => m. replace_with_state ( route, state) ,
91
81
}
@@ -101,9 +91,8 @@ impl History for AnyHistory {
101
91
Q : ToQuery ,
102
92
{
103
93
match self {
104
- #[ cfg( not( target_os = "wasi" ) ) ]
105
94
Self :: Browser ( m) => m. push_with_query ( route, query) ,
106
- # [ cfg ( not ( target_os = "wasi" ) ) ]
95
+
107
96
Self :: Hash ( m) => m. push_with_query ( route, query) ,
108
97
Self :: Memory ( m) => m. push_with_query ( route, query) ,
109
98
}
@@ -118,9 +107,8 @@ impl History for AnyHistory {
118
107
Q : ToQuery ,
119
108
{
120
109
match self {
121
- #[ cfg( not( target_os = "wasi" ) ) ]
122
110
Self :: Browser ( m) => m. replace_with_query ( route, query) ,
123
- # [ cfg ( not ( target_os = "wasi" ) ) ]
111
+
124
112
Self :: Hash ( m) => m. replace_with_query ( route, query) ,
125
113
Self :: Memory ( m) => m. replace_with_query ( route, query) ,
126
114
}
@@ -138,9 +126,8 @@ impl History for AnyHistory {
138
126
T : ' static ,
139
127
{
140
128
match self {
141
- #[ cfg( not( target_os = "wasi" ) ) ]
142
129
Self :: Browser ( m) => m. push_with_query_and_state ( route, query, state) ,
143
- # [ cfg ( not ( target_os = "wasi" ) ) ]
130
+
144
131
Self :: Hash ( m) => m. push_with_query_and_state ( route, query, state) ,
145
132
Self :: Memory ( m) => m. push_with_query_and_state ( route, query, state) ,
146
133
}
@@ -158,9 +145,8 @@ impl History for AnyHistory {
158
145
T : ' static ,
159
146
{
160
147
match self {
161
- #[ cfg( not( target_os = "wasi" ) ) ]
162
148
Self :: Browser ( m) => m. replace_with_query_and_state ( route, query, state) ,
163
- # [ cfg ( not ( target_os = "wasi" ) ) ]
149
+
164
150
Self :: Hash ( m) => m. replace_with_query_and_state ( route, query, state) ,
165
151
Self :: Memory ( m) => m. replace_with_query_and_state ( route, query, state) ,
166
152
}
@@ -171,33 +157,29 @@ impl History for AnyHistory {
171
157
CB : Fn ( ) + ' static ,
172
158
{
173
159
match self {
174
- #[ cfg( not( target_os = "wasi" ) ) ]
175
160
Self :: Browser ( m) => m. listen ( callback) ,
176
- # [ cfg ( not ( target_os = "wasi" ) ) ]
161
+
177
162
Self :: Hash ( m) => m. listen ( callback) ,
178
163
Self :: Memory ( m) => m. listen ( callback) ,
179
164
}
180
165
}
181
166
182
167
fn location ( & self ) -> Location {
183
168
match self {
184
- #[ cfg( not( target_os = "wasi" ) ) ]
185
169
Self :: Browser ( m) => m. location ( ) ,
186
- # [ cfg ( not ( target_os = "wasi" ) ) ]
170
+
187
171
Self :: Hash ( m) => m. location ( ) ,
188
172
Self :: Memory ( m) => m. location ( ) ,
189
173
}
190
174
}
191
175
}
192
176
193
- #[ cfg( not( target_os = "wasi" ) ) ]
194
177
impl From < BrowserHistory > for AnyHistory {
195
178
fn from ( m : BrowserHistory ) -> AnyHistory {
196
179
AnyHistory :: Browser ( m)
197
180
}
198
181
}
199
182
200
- #[ cfg( not( target_os = "wasi" ) ) ]
201
183
impl From < HashHistory > for AnyHistory {
202
184
fn from ( m : HashHistory ) -> AnyHistory {
203
185
AnyHistory :: Hash ( m)
0 commit comments