Skip to content

Commit

Permalink
Fix CI (#133)
Browse files Browse the repository at this point in the history
* Fix CI

* fix clippy warnings
  • Loading branch information
ranile committed Jun 25, 2021
1 parent 36ff96c commit 4872519
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
cargo-${{ runner.os }}-
- name: Install `cargo-readme`
run: cargo install cargo-readme
run: which cargo-readme || cargo install cargo-readme

- name: Test `README.md`s are up to date
run: |
Expand Down
10 changes: 5 additions & 5 deletions crates/events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl EventListenerOptions {
}

#[inline]
fn to_js(&self, once: bool) -> AddEventListenerOptions {
fn as_js(&self, once: bool) -> AddEventListenerOptions {
let mut options = AddEventListenerOptions::new();

options.capture(self.phase.is_capture());
Expand All @@ -179,8 +179,8 @@ impl Default for EventListenerOptions {
// This defaults passive to true to avoid performance issues in browsers:
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Improving_scrolling_performance_with_passive_listeners
thread_local! {
static NEW_OPTIONS: AddEventListenerOptions = EventListenerOptions::default().to_js(false);
static ONCE_OPTIONS: AddEventListenerOptions = EventListenerOptions::default().to_js(true);
static NEW_OPTIONS: AddEventListenerOptions = EventListenerOptions::default().as_js(false);
static ONCE_OPTIONS: AddEventListenerOptions = EventListenerOptions::default().as_js(true);
}

/// RAII type which is used to manage DOM event listeners.
Expand Down Expand Up @@ -462,7 +462,7 @@ impl EventListener {
target,
event_type.into(),
callback,
&options.to_js(false),
&options.as_js(false),
options.phase,
)
}
Expand Down Expand Up @@ -526,7 +526,7 @@ impl EventListener {
target,
event_type.into(),
callback,
&options.to_js(true),
&options.as_js(true),
options.phase,
)
}
Expand Down
18 changes: 7 additions & 11 deletions crates/file/src/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl File {
let blob = self.deref().slice(start, end);

let raw_mime_type = self.raw_mime_type();
let mime_type = if raw_mime_type == "" {
let mime_type = if raw_mime_type.is_empty() {
None
} else {
Some(raw_mime_type)
Expand All @@ -261,7 +261,7 @@ impl File {
File::new_(
&self.name(),
blob.into(),
mime_type.as_ref().map(|s| s.as_str()),
mime_type.as_deref(),
Some(self.last_modified_time()),
)
}
Expand Down Expand Up @@ -309,18 +309,15 @@ impl From<File> for Blob {
/// [Number.MAX_SAFE_INTEGER](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
fn safe_u64_to_f64(number: u64) -> f64 {
// Max integer stably representable by f64
// todo use js_sys::Number::MAX_SAFE_INTEGER once stable
const MAX_SAFE_INTEGER: u64 = 9007199254740991; // (2^53 - 1)
if number > MAX_SAFE_INTEGER {
if number > (js_sys::Number::MAX_SAFE_INTEGER as u64) {
throw_str("a rust number was too large and could not be represented in JavaScript");
}
number as f64
}

fn safe_u128_to_f64(number: u128) -> f64 {
// Max integer stably representable by f64
// todo use js_sys::Number::MAX_SAFE_INTEGER once stable
const MAX_SAFE_INTEGER: u128 = 9007199254740991; // (2^53 - 1)
const MAX_SAFE_INTEGER: u128 = js_sys::Number::MAX_SAFE_INTEGER as u128; // (2^53 - 1)
if number > MAX_SAFE_INTEGER {
throw_str("a rust number was too large and could not be represented in JavaScript");
}
Expand All @@ -330,12 +327,11 @@ fn safe_u128_to_f64(number: u128) -> f64 {
/// Like safe_u64_to_f64, but additionally checks that the number is an integer.
fn safe_f64_to_u64(number: f64) -> u64 {
// Max integer stably representable by f64
// todo use js_sys::Number::MAX_SAFE_INTEGER once stable
const MAX_SAFE_INTEGER: f64 = 9007199254740991.0; // (2^53 - 1)
if number > MAX_SAFE_INTEGER {
if number > js_sys::Number::MAX_SAFE_INTEGER {
throw_str("a rust number was too large and could not be represented in JavaScript");
}
if number.floor() != number {

if number.fract() != 0.0 {
throw_str(
"a number could not be converted to an integer because it was not a whole number",
);
Expand Down
5 changes: 1 addition & 4 deletions crates/file/src/file_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@ enum ReadyState {

impl ReadyState {
fn is_done(&self) -> bool {
match self {
ReadyState::Done => true,
_ => false,
}
matches!(self, ReadyState::Done)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

// Re-exports of toolkit crates.
pub use gloo_console_timer as console_timer;
pub use gloo_dialogs as dialogs;
pub use gloo_events as events;
pub use gloo_file as file;
pub use gloo_render as render;
pub use gloo_storage as storage;
pub use gloo_timers as timers;
pub use gloo_dialogs as dialogs;
pub use gloo_render as render;

0 comments on commit 4872519

Please sign in to comment.