Skip to content

Commit

Permalink
migrate from nightly to stable rust
Browse files Browse the repository at this point in the history
  • Loading branch information
figsoda committed Feb 5, 2021
1 parent 37fc4dc commit 0bf8e6e
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 73 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
target: ${{ matrix.target }}
override: true

Expand All @@ -49,7 +49,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
components: clippy
override: true

Expand All @@ -70,7 +70,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
components: rustfmt
override: true

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
with:
command: build
args: --release --target ${{ matrix.target }}
env:
RUSTFLAGS: -Z strip=symbols

- name: Upload release asset
uses: actions/upload-release-asset@v1
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["strip"]

[package]
name = "mmtc"
version = "0.2.8"
Expand Down Expand Up @@ -35,4 +33,3 @@ features = ["crossterm", "serde"]
lto = true
panic = "abort"
codegen-units = 1
strip = "symbols"
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@ Minimal [mpd](https://github.com/musicplayerdaemon/mpd) terminal client that aim
The latest precompiled binaries are available on [github](https://github.com/figsoda/mmtc/releases/latest).

Alternatively you can install mmtc from [crates.io][Crate] with cargo.
This requires the nightly toolchain of [Rust].

```sh
cargo +nightly install mmtc
cargo install mmtc
```


## Building from source

This requires the nightly toolchain of [Rust].

```sh
cargo +nightly build --release
cargo build --release
```


Expand Down Expand Up @@ -101,4 +98,3 @@ See [CHANGELOG.md]
[Crate]: https://crates.io/crates/mmtc
[Configuration.md]: Configuration.md
[CHANGELOG.md]: CHANGELOG.md
[Rust]: https://www.rust-lang.org/tools/install
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<'de> Deserialize<'de> for Texts {
.ok_or_else(|| de::Error::invalid_length(0, &self))?,
sa.next_element()?.map_or_else(
|| Err(de::Error::invalid_length(1, &self)),
|x| Ok(box x),
|x| Ok(Box::new(x)),
)?,
sa.next_element()?.map(Box::new),
))
Expand Down
128 changes: 77 additions & 51 deletions src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,28 @@ pub fn layout() -> Widget {
12,
Widget::Textbox(Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(122)), AddStyle::Bold],
box Texts::Text(String::from("Title")),
Box::new(Texts::Text(String::from("Title"))),
)),
),
Constrained::Ratio(
10,
Widget::Textbox(Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(158)), AddStyle::Bold],
box Texts::Text(String::from("Artist")),
Box::new(Texts::Text(String::from("Artist"))),
)),
),
Constrained::Ratio(
10,
Widget::Textbox(Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(194)), AddStyle::Bold],
box Texts::Text(String::from("Album")),
Box::new(Texts::Text(String::from("Album"))),
)),
),
Constrained::Ratio(
1,
Widget::Textbox(Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(230)), AddStyle::Bold],
box Texts::Text(String::from("Time")),
Box::new(Texts::Text(String::from("Time"))),
)),
),
]),
Expand All @@ -87,8 +87,11 @@ pub fn layout() -> Widget {
12,
Texts::If(
Condition::QueueCurrent,
box Texts::Styled(vec![AddStyle::Italic], box Texts::QueueTitle),
Some(box Texts::QueueTitle),
Box::new(Texts::Styled(
vec![AddStyle::Italic],
Box::new(Texts::QueueTitle),
)),
Some(Box::new(Texts::QueueTitle)),
),
),
style: vec![AddStyle::Fg(Color::Indexed(75))],
Expand All @@ -103,8 +106,11 @@ pub fn layout() -> Widget {
10,
Texts::If(
Condition::QueueCurrent,
box Texts::Styled(vec![AddStyle::Italic], box Texts::QueueArtist),
Some(box Texts::QueueArtist),
Box::new(Texts::Styled(
vec![AddStyle::Italic],
Box::new(Texts::QueueArtist),
)),
Some(Box::new(Texts::QueueArtist)),
),
),
style: vec![AddStyle::Fg(Color::Indexed(111))],
Expand All @@ -119,8 +125,11 @@ pub fn layout() -> Widget {
10,
Texts::If(
Condition::QueueCurrent,
box Texts::Styled(vec![AddStyle::Italic], box Texts::QueueAlbum),
Some(box Texts::QueueAlbum),
Box::new(Texts::Styled(
vec![AddStyle::Italic],
Box::new(Texts::QueueAlbum),
)),
Some(Box::new(Texts::QueueAlbum)),
),
),
style: vec![AddStyle::Fg(Color::Indexed(147))],
Expand All @@ -135,8 +144,11 @@ pub fn layout() -> Widget {
1,
Texts::If(
Condition::QueueCurrent,
box Texts::Styled(vec![AddStyle::Italic], box Texts::QueueDuration),
Some(box Texts::QueueDuration),
Box::new(Texts::Styled(
vec![AddStyle::Italic],
Box::new(Texts::QueueDuration),
)),
Some(Box::new(Texts::QueueDuration)),
),
),
style: vec![AddStyle::Fg(Color::Indexed(183))],
Expand All @@ -155,108 +167,122 @@ pub fn layout() -> Widget {
0,
Widget::Textbox(Texts::Styled(
vec![AddStyle::Bold],
box Texts::If(
Box::new(Texts::If(
Condition::Searching,
box Texts::Parts(vec![
Box::new(Texts::Parts(vec![
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(113))],
box Texts::Text(String::from("Searching: ")),
Box::new(Texts::Text(String::from("Searching: "))),
),
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(185))],
box Texts::Query,
Box::new(Texts::Query),
),
]),
Some(box Texts::If(
Condition::Not(box Condition::Stopped),
box Texts::Parts(vec![
])),
Some(Box::new(Texts::If(
Condition::Not(Box::new(Condition::Stopped)),
Box::new(Texts::Parts(vec![
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(113))],
box Texts::Parts(vec![
Box::new(Texts::Parts(vec![
Texts::If(
Condition::Playing,
box Texts::Text(String::from("[playing: ")),
Some(box Texts::Text(String::from("[paused: "))),
Box::new(Texts::Text(String::from("[playing: "))),
Some(Box::new(Texts::Text(String::from(
"[paused: ",
)))),
),
Texts::CurrentElapsed,
Texts::Text(String::from("/")),
Texts::CurrentDuration,
Texts::Text(String::from("] ")),
]),
])),
),
Texts::If(
Condition::TitleExist,
box Texts::Parts(vec![
Box::new(Texts::Parts(vec![
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(149))],
box Texts::CurrentTitle,
Box::new(Texts::CurrentTitle),
),
Texts::If(
Condition::ArtistExist,
box Texts::Parts(vec![
Box::new(Texts::Parts(vec![
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(216))],
box Texts::Text(String::from(" ◆ ")),
Box::new(Texts::Text(String::from(" ◆ "))),
),
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(185))],
box Texts::CurrentArtist,
Box::new(Texts::CurrentArtist),
),
Texts::If(
Condition::AlbumExist,
box Texts::Parts(vec![
Box::new(Texts::Parts(vec![
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(
216,
))],
box Texts::Text(String::from(
" ◆ ",
Box::new(Texts::Text(
String::from(" ◆ "),
)),
),
Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(
221,
))],
box Texts::CurrentAlbum,
Box::new(Texts::CurrentAlbum),
),
]),
])),
None,
),
]),
])),
None,
),
]),
Some(box Texts::Styled(
])),
Some(Box::new(Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(185))],
box Texts::CurrentFile,
)),
Box::new(Texts::CurrentFile),
))),
),
]),
])),
None,
)),
),
))),
)),
)),
),
Constrained::Fixed(
7,
Widget::TextboxR(Texts::Styled(
vec![AddStyle::Fg(Color::Indexed(81))],
box Texts::Parts(vec![
Box::new(Texts::Parts(vec![
Texts::Text(String::from("[")),
Texts::If(Condition::Repeat, box Texts::Text(String::from("@")), None),
Texts::If(Condition::Random, box Texts::Text(String::from("#")), None),
Texts::If(
Condition::Repeat,
Box::new(Texts::Text(String::from("@"))),
None,
),
Texts::If(
Condition::Random,
Box::new(Texts::Text(String::from("#"))),
None,
),
Texts::If(
Condition::Single,
box Texts::Text(String::from("^")),
Some(box Texts::If(
Box::new(Texts::Text(String::from("^"))),
Some(Box::new(Texts::If(
Condition::Oneshot,
box Texts::Text(String::from("!")),
Box::new(Texts::Text(String::from("!"))),
None,
)),
))),
),
Texts::If(
Condition::Consume,
Box::new(Texts::Text(String::from("*"))),
None,
),
Texts::If(Condition::Consume, box Texts::Text(String::from("*")), None),
Texts::Text(String::from("]")),
]),
])),
)),
),
]),
Expand Down
14 changes: 7 additions & 7 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
Texts::Query => {
spans.push(Span::styled(String::from(s.query), *s.style));
}
Texts::Styled(styles, box xs) => {
Texts::Styled(styles, xs) => {
_flatten(
spans,
xs,
Expand All @@ -387,7 +387,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
_flatten(spans, xs, s);
}
}
Texts::If(cond, box xs, Some(box ys)) => {
Texts::If(cond, xs, Some(ys)) => {
_flatten(
spans,
if eval_cond(
Expand All @@ -408,7 +408,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
s,
);
}
Texts::If(cond, box xs, None) => {
Texts::If(cond, xs, None) => {
if eval_cond(
cond,
&ConditionState {
Expand Down Expand Up @@ -518,9 +518,9 @@ fn eval_cond(cond: &Condition, s: &ConditionState) -> bool {
Condition::Selected => s.selected,
Condition::Searching => s.searching,
Condition::Filtered => !s.query.is_empty(),
Condition::Not(box x) => !eval_cond(x, s),
Condition::And(box x, box y) => eval_cond(x, s) && eval_cond(y, s),
Condition::Or(box x, box y) => eval_cond(x, s) || eval_cond(y, s),
Condition::Xor(box x, box y) => eval_cond(x, s) ^ eval_cond(y, s),
Condition::Not(x) => !eval_cond(x, s),
Condition::And(x, y) => eval_cond(x, s) && eval_cond(y, s),
Condition::Or(x, y) => eval_cond(x, s) || eval_cond(y, s),
Condition::Xor(x, y) => eval_cond(x, s) ^ eval_cond(y, s),
}
}
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(clippy::too_many_arguments)]
#![feature(box_patterns, box_syntax, destructuring_assignment)]
#![forbid(unsafe_code)]

mod app;
Expand Down Expand Up @@ -478,7 +477,9 @@ async fn run() -> Result<()> {

// conditionally update queue
if updates & 0b010 == 0b010 {
(s.queue, queue_strings) = cl.queue(s.status.queue_len, &cfg.search_fields).await?;
let queue = cl.queue(s.status.queue_len, &cfg.search_fields).await?;
s.queue = queue.0;
queue_strings = queue.1;
s.liststate.select(None);
s.reselect();
if !s.query.is_empty() {
Expand Down

0 comments on commit 0bf8e6e

Please sign in to comment.