Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ea9bd2

Browse files
committed
Fix clippy lints
1 parent4f7feb9 commit7ea9bd2

File tree

2 files changed

+60
-55
lines changed

2 files changed

+60
-55
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses:actions-rs/cargo@v1
3131
with:
3232
command:clippy
33-
args:--all-targets --all-features
33+
args:--all-targets --all-features -- -D clippy::all
3434

3535
-name:Lint with Black
3636
run:pip install black && black --check .

‎src/lib.rs‎

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
trivial_casts,
88
trivial_numeric_casts,
99
unsafe_code,
10-
unused_qualifications
10+
unused_qualifications,
11+
deprecated
1112
)]
1213

1314
use adblock::blocker::BlockerErrorasRustBlockerError;
@@ -99,15 +100,15 @@ pub struct BlockerResult {
99100
puberror:Option<String>,
100101
}
101102

102-
implInto<BlockerResult>forRustBlockerResult{
103-
fninto(self) ->BlockerResult{
104-
BlockerResult{
105-
matched:self.matched,
106-
important:self.important,
107-
redirect:self.redirect,
108-
exception:self.exception,
109-
filter:self.filter,
110-
error:self.error,
103+
implFrom<RustBlockerResult>forBlockerResult{
104+
fnfrom(br:RustBlockerResult) ->Self{
105+
Self{
106+
matched:br.matched,
107+
important:br.important,
108+
redirect:br.redirect,
109+
exception:br.exception,
110+
filter:br.filter,
111+
error:br.error,
111112
}
112113
}
113114
}
@@ -166,27 +167,27 @@ create_exception!(adblock, OptimizedFilterExistence, BlockerException);
166167
create_exception!(adblock,BadFilterAddUnsupported,BlockerException);
167168
create_exception!(adblock,FilterExists,BlockerException);
168169

169-
implInto<PyErr>forBlockerError{
170-
fninto(self) ->PyErr{
171-
let msg =format!("{:?}",self);
172-
matchself{
173-
Self::SerializationError =>PyErr::new::<SerializationError,_>(msg),
174-
Self::DeserializationError =>PyErr::new::<DeserializationError,_>(msg),
175-
Self::OptimizedFilterExistence =>PyErr::new::<OptimizedFilterExistence,_>(msg),
176-
Self::BadFilterAddUnsupported =>PyErr::new::<BadFilterAddUnsupported,_>(msg),
177-
Self::FilterExists =>PyErr::new::<FilterExists,_>(msg),
170+
implFrom<BlockerError>forPyErr{
171+
fnfrom(err:BlockerError) ->Self{
172+
let msg =format!("{:?}",err);
173+
matcherr{
174+
BlockerError::SerializationError =>Self::new::<SerializationError,_>(msg),
175+
BlockerError::DeserializationError =>Self::new::<DeserializationError,_>(msg),
176+
BlockerError::OptimizedFilterExistence =>Self::new::<OptimizedFilterExistence,_>(msg),
177+
BlockerError::BadFilterAddUnsupported =>Self::new::<BadFilterAddUnsupported,_>(msg),
178+
BlockerError::FilterExists =>Self::new::<FilterExists,_>(msg),
178179
}
179180
}
180181
}
181182

182-
implInto<BlockerError>forRustBlockerError{
183-
fninto(self) ->BlockerError{
184-
matchself{
185-
Self::SerializationError =>BlockerError::SerializationError,
186-
Self::DeserializationError =>BlockerError::DeserializationError,
187-
Self::OptimizedFilterExistence =>BlockerError::OptimizedFilterExistence,
188-
Self::BadFilterAddUnsupported =>BlockerError::BadFilterAddUnsupported,
189-
Self::FilterExists =>BlockerError::FilterExists,
183+
implFrom<RustBlockerError>forBlockerError{
184+
fnfrom(err:RustBlockerError) ->Self{
185+
matcherr{
186+
RustBlockerError::SerializationError =>Self::SerializationError,
187+
RustBlockerError::DeserializationError =>Self::DeserializationError,
188+
RustBlockerError::OptimizedFilterExistence =>Self::OptimizedFilterExistence,
189+
RustBlockerError::BadFilterAddUnsupported =>Self::BadFilterAddUnsupported,
190+
RustBlockerError::FilterExists =>Self::FilterExists,
190191
}
191192
}
192193
}
@@ -206,7 +207,7 @@ fn filter_format_from_string(filter_format: &str) -> PyResult<FilterFormat> {
206207
/// created. FilterSet allows assembling a compound list from multiple
207208
/// different sources before compiling the rules into an Engine.
208209
#[pyclass]
209-
#[text_signature ="($self, debug)"]
210+
#[pyo3(text_signature ="($self, debug)")]
210211
#[derive(Clone)]
211212
pubstructFilterSet{
212213
filter_set:RustFilterSet,
@@ -233,7 +234,7 @@ impl FilterSet {
233234
///
234235
/// The format is a string containing either "standard" (ABP/uBO-style)
235236
/// or "hosts".
236-
#[text_signature ="($self, filter_list, format)"]
237+
#[pyo3(text_signature ="($self, filter_list, format)")]
237238
#[args(filter_list, format ="\"standard\"")]
238239
pubfnadd_filter_list(&mutself,filter_list:&str,format:&str) ->PyResult<()>{
239240
let filter_format =filter_format_from_string(format)?;
@@ -246,7 +247,7 @@ impl FilterSet {
246247
///
247248
/// The format is a string containing either "standard" (ABP/uBO-style)
248249
/// or "hosts".
249-
#[text_signature ="($self, filters, format)"]
250+
#[pyo3(text_signature ="($self, filters, format)")]
250251
#[args(filters, format ="\"standard\"")]
251252
pubfnadd_filters(&mutself,filters:Vec<String>,format:&str) ->PyResult<()>{
252253
let filter_format =filter_format_from_string(format)?;
@@ -291,14 +292,14 @@ pub struct UrlSpecificResources {
291292
pubgenerichide:bool,
292293
}
293294

294-
implInto<UrlSpecificResources>forRustUrlSpecificResources{
295-
fninto(self) ->UrlSpecificResources{
296-
UrlSpecificResources{
297-
hide_selectors:self.hide_selectors,
298-
style_selectors:self.style_selectors,
299-
exceptions:self.exceptions,
300-
injected_script:self.injected_script,
301-
generichide:self.generichide,
295+
implFrom<RustUrlSpecificResources>forUrlSpecificResources{
296+
fnfrom(r:RustUrlSpecificResources) ->Self{
297+
Self{
298+
hide_selectors:r.hide_selectors,
299+
style_selectors:r.style_selectors,
300+
exceptions:r.exceptions,
301+
injected_script:r.injected_script,
302+
generichide:r.generichide,
302303
}
303304
}
304305
}
@@ -337,7 +338,7 @@ impl PyObjectProtocol for UrlSpecificResources {
337338
///
338339
/// [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType
339340
#[pyclass]
340-
#[text_signature ="($self, filter_set, optimize)"]
341+
#[pyo3(text_signature ="($self, filter_set, optimize)")]
341342
pubstructEngine{
342343
engine:RustEngine,
343344
optimize:bool,
@@ -361,7 +362,7 @@ impl Engine {
361362
/// * `url` - The URL of the request to check
362363
/// * `source_url` - The URL from where the request is made
363364
/// * `request_type` - The resource type that the request points to
364-
#[text_signature ="($self, url, source_url, request_type)"]
365+
#[pyo3(text_signature ="($self, url, source_url, request_type)")]
365366
pubfncheck_network_urls(
366367
&self,
367368
url:&str,
@@ -384,7 +385,9 @@ impl Engine {
384385
/// * `third_party_request` - Is the given request to a third-party? Here,
385386
/// `None` can be given and the engine will figure it out based on the
386387
/// `hostname` and `source_hostname`.
387-
#[text_signature ="($self, url, hostname, source_hostname, requsest_type, third_party_request)"]
388+
#[pyo3(
389+
text_signature ="($self, url, hostname, source_hostname, requsest_type, third_party_request)"
390+
)]
388391
pubfncheck_network_urls_with_hostnames(
389392
&self,
390393
url:&str,
@@ -416,8 +419,10 @@ impl Engine {
416419
/// * `previously_matched_rule` - Return a match as long as there are no
417420
/// exceptions
418421
/// * `force_check_exceptions` - Check exceptions even if no other rule matches
419-
#[text_signature ="($self, url, hostname, source_hostname, request_type,\
420-
third_party_request, previously_matched_rule, force_check_exceptions)"]
422+
#[pyo3(
423+
text_signature ="($self, url, hostname, source_hostname, request_type,\
424+
third_party_request, previously_matched_rule, force_check_exceptions)"
425+
)]
421426
#[allow(clippy::too_many_arguments)]
422427
pubfncheck_network_urls_with_hostnames_subset(
423428
&self,
@@ -443,7 +448,7 @@ impl Engine {
443448

444449
/// Serialize this blocking engine to bytes. They can then be deserialized
445450
/// using `deserialize()` to get the same engine again.
446-
#[text_signature ="($self)"]
451+
#[pyo3(text_signature ="($self)")]
447452
pubfnserialize<'p>(&mutself,py:Python<'p>) ->PyResult<&'pPyBytes>{
448453
let bytes =self.serialize_inner()?;
449454
let py_bytes =PyBytes::new(py,&bytes);
@@ -464,7 +469,7 @@ impl Engine {
464469
/// Serialize this blocking engine to a file. The file can then be
465470
/// deserialized using `deserialize_from_file()` to get the same engine
466471
/// again.
467-
#[text_signature ="($self, file)"]
472+
#[pyo3(text_signature ="($self, file)")]
468473
pubfnserialize_to_file(&mutself,file:&str) ->PyResult<()>{
469474
let data =self.serialize_inner()?;
470475
letmut fd = fs::OpenOptions::new()
@@ -477,7 +482,7 @@ impl Engine {
477482
}
478483

479484
/// Deserialize a blocking engine from bytes produced with `serialize()`.
480-
#[text_signature ="($self, serialized)"]
485+
#[pyo3(text_signature ="($self, serialized)")]
481486
pubfndeserialize(&mutself,serialized:&[u8]) ->PyResult<()>{
482487
let result =self.engine.deserialize(serialized);
483488
match result{
@@ -491,7 +496,7 @@ impl Engine {
491496

492497
/// Deserialize a blocking engine from file produced with
493498
/// `serialize_to_file()`.
494-
#[text_signature ="($self, file)"]
499+
#[pyo3(text_signature ="($self, file)")]
495500
pubfndeserialize_from_file(&mutself,file:&str) ->PyResult<()>{
496501
letmut fd = fs::File::open(file)?;
497502
letmut data:Vec<u8> =Vec::new();
@@ -500,7 +505,7 @@ impl Engine {
500505
}
501506

502507
/// Checks if the given filter exists in the blocking engine.
503-
#[text_signature ="($self, filter)"]
508+
#[pyo3(text_signature ="($self, filter)")]
504509
pubfnfilter_exists(&self,filter:&str) ->bool{
505510
self.engine.filter_exists(filter)
506511
}
@@ -509,7 +514,7 @@ impl Engine {
509514
///
510515
/// Tags can be used to cheaply enable or disable network rules with a
511516
/// corresponding $tag option.
512-
#[text_signature ="($self, tags)"]
517+
#[pyo3(text_signature ="($self, tags)")]
513518
pubfnuse_tags(&mutself,tags:Vec<&str>){
514519
self.engine.use_tags(&tags);
515520
}
@@ -519,7 +524,7 @@ impl Engine {
519524
///
520525
/// Tags can be used to cheaply enable or disable network rules with a
521526
/// corresponding $tag option.
522-
#[text_signature ="($self, tags)"]
527+
#[pyo3(text_signature ="($self, tags)")]
523528
pubfnenable_tags(&mutself,tags:Vec<&str>){
524529
self.engine.enable_tags(&tags);
525530
}
@@ -529,7 +534,7 @@ impl Engine {
529534
///
530535
/// Tags can be used to cheaply enable or disable network rules with a
531536
/// corresponding $tag option.
532-
#[text_signature ="($self, tags)"]
537+
#[pyo3(text_signature ="($self, tags)")]
533538
pubfndisable_tags(&mutself,tags:Vec<&str>){
534539
self.engine.disable_tags(&tags);
535540
}
@@ -538,7 +543,7 @@ impl Engine {
538543
///
539544
/// Tags can be used to cheaply enable or disable network rules with a
540545
/// corresponding $tag option.
541-
#[text_signature ="($self, tag)"]
546+
#[pyo3(text_signature ="($self, tag)")]
542547
pubfntag_exists(&self,tag:&str) ->bool{
543548
self.engine.tag_exists(tag)
544549
}
@@ -547,7 +552,7 @@ impl Engine {
547552
/// url. Once this has been called, all CSS ids and classes on a
548553
/// page should be passed to hidden_class_id_selectors to obtain any
549554
/// stylesheets consisting of generic rules.
550-
#[text_signature ="($self, url)"]
555+
#[pyo3(text_signature ="($self, url)")]
551556
pubfnurl_cosmetic_resources(&self,url:&str) ->UrlSpecificResources{
552557
self.engine.url_cosmetic_resources(url).into()
553558
}
@@ -559,7 +564,7 @@ impl Engine {
559564
/// are not excepted.
560565
///
561566
/// Exceptions should be passed directly from UrlSpecificResources.
562-
#[text_signature ="($self, classes, ids, exceptions)"]
567+
#[pyo3(text_signature ="($self, classes, ids, exceptions)")]
563568
pubfnhidden_class_id_selectors(
564569
&self,
565570
classes:Vec<String>,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp