Merge branch 'main' into zed2
This commit is contained in:
commit
4a6a17d866
238 changed files with 17140 additions and 6659 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::http::HttpClient;
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use futures::AsyncReadExt;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
|
@ -16,6 +16,7 @@ pub struct GithubRelease {
|
|||
pub pre_release: bool,
|
||||
pub assets: Vec<GithubReleaseAsset>,
|
||||
pub tarball_url: String,
|
||||
pub zipball_url: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
@ -45,6 +46,14 @@ pub async fn latest_github_release(
|
|||
.await
|
||||
.context("error reading latest release")?;
|
||||
|
||||
if response.status().is_client_error() {
|
||||
let text = String::from_utf8_lossy(body.as_slice());
|
||||
bail!(
|
||||
"status error {}, response: {text:?}",
|
||||
response.status().as_u16()
|
||||
);
|
||||
}
|
||||
|
||||
let releases = match serde_json::from_slice::<Vec<GithubRelease>>(body.as_slice()) {
|
||||
Ok(releases) => releases,
|
||||
|
||||
|
|
|
@ -350,19 +350,19 @@ pub fn unzip_option<T, U>(option: Option<(T, U)>) -> (Option<T>, Option<U>) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Immediately invoked function expression. Good for using the ? operator
|
||||
/// Evaluates to an immediately invoked function expression. Good for using the ? operator
|
||||
/// in functions which do not return an Option or Result
|
||||
#[macro_export]
|
||||
macro_rules! iife {
|
||||
macro_rules! maybe {
|
||||
($block:block) => {
|
||||
(|| $block)()
|
||||
};
|
||||
}
|
||||
|
||||
/// Async Immediately invoked function expression. Good for using the ? operator
|
||||
/// in functions which do not return an Option or Result. Async version of above
|
||||
/// Evaluates to an immediately invoked function expression. Good for using the ? operator
|
||||
/// in functions which do not return an Option or Result, but async.
|
||||
#[macro_export]
|
||||
macro_rules! async_iife {
|
||||
macro_rules! async_maybe {
|
||||
($block:block) => {
|
||||
(|| async move { $block })()
|
||||
};
|
||||
|
@ -449,7 +449,7 @@ mod tests {
|
|||
None
|
||||
}
|
||||
|
||||
let foo = iife!({
|
||||
let foo = maybe!({
|
||||
option_returning_function()?;
|
||||
Some(())
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue