mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Workaround for Rust versions below 1.91.0
This commit is contained in:
parent
27170ce70b
commit
c91628484e
2 changed files with 11 additions and 5 deletions
|
|
@ -84,7 +84,9 @@ impl LocBuf {
|
||||||
Ok(Self { inner: loc.inner, uri, urn })
|
Ok(Self { inner: loc.inner, uri, urn })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn empty() -> Self { Self { inner: PathBuf::new(), uri: 0, urn: 0 } }
|
// FIXME: use `LocBuf::empty()` when Rust 1.91.0 released
|
||||||
|
// pub const fn empty() -> Self { Self { inner: PathBuf::new(), uri: 0, urn: 0 }
|
||||||
|
// }
|
||||||
|
|
||||||
pub fn zeroed(path: impl Into<PathBuf>) -> Self {
|
pub fn zeroed(path: impl Into<PathBuf>) -> Self {
|
||||||
let loc = Self::from(path.into());
|
let loc = Self::from(path.into());
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, hash::BuildHasher, path::{Path, PathBuf}, str::FromStr};
|
use std::{borrow::Cow, ffi::OsStr, fmt::{Debug, Formatter}, hash::BuildHasher, path::{Path, PathBuf}, str::FromStr, sync::OnceLock};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
@ -80,9 +80,13 @@ impl PartialEq<Url<'_>> for &UrlBuf {
|
||||||
|
|
||||||
impl UrlBuf {
|
impl UrlBuf {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new() -> &'static Self {
|
pub fn new() -> &'static Self {
|
||||||
static U: UrlBuf = UrlBuf { loc: LocBuf::empty(), scheme: Scheme::Regular };
|
static U: OnceLock<UrlBuf> = OnceLock::new();
|
||||||
&U
|
U.get_or_init(Self::default)
|
||||||
|
|
||||||
|
// FIXME: use `LocBuf::empty()` when Rust 1.91.0 released
|
||||||
|
// static U: UrlBuf = UrlBuf { loc: LocBuf::empty(), scheme: Scheme::Regular
|
||||||
|
// }; &U
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue