Change from try (reserved keyword) to maybe

This commit is contained in:
Mikayla 2023-10-25 07:10:21 -07:00
parent beb0af9763
commit 26a3d41dc7
No known key found for this signature in database
7 changed files with 22 additions and 22 deletions

View File

@ -944,7 +944,7 @@ async fn create_room(
let live_kit_room = live_kit_room.clone();
let live_kit = session.live_kit_client.as_ref();
util::async_iife!({
util::async_maybe!({
let live_kit = live_kit?;
let token = live_kit

View File

@ -46,7 +46,7 @@ use serde_derive::{Deserialize, Serialize};
use settings::SettingsStore;
use std::{borrow::Cow, hash::Hash, mem, sync::Arc};
use theme::{components::ComponentExt, IconButton, Interactive};
use util::{iife, ResultExt, TryFutureExt};
use util::{maybe, ResultExt, TryFutureExt};
use workspace::{
dock::{DockPosition, Panel},
item::ItemHandle,
@ -1487,7 +1487,7 @@ impl CollabPanel {
let text = match section {
Section::ActiveCall => {
let channel_name = iife!({
let channel_name = maybe!({
let channel_id = ActiveCall::global(cx).read(cx).channel_id(cx)?;
let channel = self.channel_store.read(cx).channel_for_id(channel_id)?;
@ -1929,7 +1929,7 @@ impl CollabPanel {
self.selected_channel().map(|channel| channel.0.id) == Some(channel.id);
let disclosed = has_children.then(|| !self.collapsed_channels.binary_search(&path).is_ok());
let is_active = iife!({
let is_active = maybe!({
let call_channel = ActiveCall::global(cx)
.read(cx)
.room()?
@ -2817,7 +2817,7 @@ impl CollabPanel {
}
}
ListEntry::Channel { channel, .. } => {
let is_active = iife!({
let is_active = maybe!({
let call_channel = ActiveCall::global(cx)
.read(cx)
.room()?

View File

@ -20,7 +20,7 @@ use std::future::Future;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use util::channel::ReleaseChannel;
use util::{async_iife, ResultExt};
use util::{async_maybe, ResultExt};
const CONNECTION_INITIALIZE_QUERY: &'static str = sql!(
PRAGMA foreign_keys=TRUE;
@ -57,7 +57,7 @@ pub async fn open_db<M: Migrator + 'static>(
let release_channel_name = release_channel.dev_name();
let main_db_dir = db_dir.join(Path::new(&format!("0-{}", release_channel_name)));
let connection = async_iife!({
let connection = async_maybe!({
smol::fs::create_dir_all(&main_db_dir)
.await
.context("Could not create db directory")

View File

@ -4,7 +4,7 @@ use collections::HashMap;
use gpui::{AppContext, AssetSource};
use serde_derive::Deserialize;
use util::{iife, paths::PathExt};
use util::{maybe, paths::PathExt};
#[derive(Deserialize, Debug)]
struct TypeConfig {
@ -42,12 +42,12 @@ impl FileAssociations {
}
pub fn get_icon(path: &Path, cx: &AppContext) -> Arc<str> {
iife!({
maybe!({
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
// FIXME: Associate a type with the languages and have the file's langauge
// override these associations
iife!({
maybe!({
let suffix = path.icon_suffix()?;
this.suffixes
@ -61,7 +61,7 @@ impl FileAssociations {
}
pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
iife!({
maybe!({
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
let key = if expanded {
@ -78,7 +78,7 @@ impl FileAssociations {
}
pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
iife!({
maybe!({
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
let key = if expanded {

View File

@ -349,19 +349,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! try {
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_try {
macro_rules! async_maybe {
($block:block) => {
(|| async move { $block })()
};
@ -434,7 +434,7 @@ mod tests {
None
}
let foo = iife!({
let foo = maybe!({
option_returning_function()?;
Some(())
});

View File

@ -19,7 +19,7 @@ use std::{
},
};
use util::{
async_iife,
async_maybe,
fs::remove_matching,
github::{latest_github_release, GitHubLspBinaryVersion},
ResultExt,
@ -421,7 +421,7 @@ impl LspAdapter for NextLspAdapter {
}
async fn get_cached_server_binary_next(container_dir: PathBuf) -> Option<LanguageServerBinary> {
async_iife!({
async_maybe!({
let mut last_binary_path = None;
let mut entries = fs::read_dir(&container_dir).await?;
while let Some(entry) = entries.next().await {

View File

@ -8,7 +8,7 @@ use lsp::LanguageServerBinary;
use smol::fs;
use std::{any::Any, env::consts, path::PathBuf};
use util::{
async_iife,
async_maybe,
github::{latest_github_release, GitHubLspBinaryVersion},
ResultExt,
};
@ -106,7 +106,7 @@ impl super::LspAdapter for LuaLspAdapter {
}
async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServerBinary> {
async_iife!({
async_maybe!({
let mut last_binary_path = None;
let mut entries = fs::read_dir(&container_dir).await?;
while let Some(entry) = entries.next().await {