commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
cf5a68c5cd97515269144f0ad2735d43c961559d | dylni | 2020-04-23T18:56:57 | BREAKING: OsStr/Path methods now use FromUtf8Error
Previously, they would just return 'Vec<u8>' as the error type. But a
'FromUtf8Error' gives strictly more information, so we return that
instead.
Closes #52 | diff --git a/src/ext_vec.rs b/src/ext_vec.rs
index 5beb0e1..73eb3b3 100644
--- a/src/ext_vec.rs
+++ b/src/ext_vec.rs
@@ -486,13 +486,13 @@ pub trait ByteVec: Sealed {
/// assert_eq!(os_str, OsStr::new("foo"));
/// ```
#[inline]
- fn into_os_string(self) -> Result<OsString, Vec<u8>>
+ fn into_os_str... | 1 | 5 | 8 |
84718cbf78553d1b86a50dd5405d7e9ef017dd6a | Thom Chiovoloni | 2021-04-13T15:35:07 | api: add ByteSlice::r?split_once_str
Closes #85 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 6ffd81b..8967c46 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -1193,6 +1193,94 @@ pub trait ByteSlice: Sealed {
Split::new(self.as_bytes(), splitter.as_ref())
}
+ /// Split this byte string at the first occurance of `splitter`.
+ //... | 1 | 88 | 0 |
d6ea32916c42508df791ba429da0b6b4da8aad47 | Ryan Lopopolo | 2021-06-30T02:49:15 | perf: fix capacity overflow and improve perf
This implements 'ByteSlice::repeatn' with '<[u8]>::repeat'.
'repeat' on slices is stable since Rust 1.40.0 and does an exponential
'ptr::copy_nonoverlapping'. The implementation in 'alloc' also correctly
handles the capacity overflow when 'len * n' is more than 'usize::MAX... | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 8512795..6ffd81b 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -587,12 +587,7 @@ pub trait ByteSlice: Sealed {
#[cfg(feature = "std")]
#[inline]
fn repeatn(&self, n: usize) -> Vec<u8> {
- let bs = self.as_bytes();
- let mut ds... | 1 | 1 | 6 |
b71e296d7edb71bd9dc29502bdad5914601543e2 | liudingming | 2021-08-09T06:00:01 | api: impl From<&BStr> for &[u8]
Fixes #93, Closes #94 | diff --git a/src/impls.rs b/src/impls.rs
index 85a27ba..42b81d1 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -590,6 +590,13 @@ mod bstr {
}
}
+ impl<'a> From<&'a BStr> for &'a [u8] {
+ #[inline]
+ fn from(s: &'a BStr) -> &'a [u8] {
+ BStr::as_bytes(s)
+ }
+ }
+
... | 1 | 7 | 0 |
13dfa9888d8c9b1d5de6ca98cf96790fb8480acd | Andres Suarez | 2021-09-04T20:53:05 | api: impl DoubleEndedIterator and FusedIterator for line iterators
Closes #97 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 55bb016..8512795 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -3559,17 +3559,19 @@ impl<'a> Iterator for Lines<'a> {
#[inline]
fn next(&mut self) -> Option<&'a [u8]> {
- let mut line = self.it.next()?;
- if line.last_byte() == S... | 1 | 95 | 9 |
0dfcabf7ec0167c33dfcecf4524a49f12f7a2bcf | Andres Suarez | 2021-08-30T21:51:19 | api: impl Clone and Debug for Lines and LinesWithTerminator
Closes #96 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 6d52ce7..55bb016 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -3521,6 +3521,7 @@ impl<'a> Iterator for SplitNReverse<'a> {
/// `\n`.
///
/// `'a` is the lifetime of the byte string being iterated over.
+#[derive(Clone, Debug)]
pub struct Lines<'a> {
... | 1 | 2 | 0 |
e19eeb3e838f405557c2af7a4928d96f85523145 | Andrew Gallant | 2022-07-05T18:15:27 | BREAKING: rename 'Bytes::as_slice' to 'Bytes::as_bytes'
This is a more specific name given that we know we're dealing with a
'&[u8]'. | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 71ab3a2..6d52ce7 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -3215,7 +3215,7 @@ impl<'a> Bytes<'a> {
/// This has the same lifetime as the original slice,
/// and so the iterator can continue to be used while this exists.
#[inline]
- p... | 1 | 1 | 1 |
ac08a562d3b411b156b2c9050e214489d0c4f548 | Sebastian Thiel | 2022-03-18T08:49:12 | api: add 'as_bytes()' to line iterators
Allowing access to the buffer itself may make some use cases simpler
when access to the original buffer after consuming a few lines is
preferrable.
Without it, one would have to find a way to count the consumed bytes
themselves.
Closes #101 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 2e9ce88..71ab3a2 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -3529,6 +3529,28 @@ impl<'a> Lines<'a> {
fn new(bytes: &'a [u8]) -> Lines<'a> {
Lines { it: LinesWithTerminator::new(bytes) }
}
+
+ /// Return a copy of the rest of the u... | 1 | 44 | 0 |
f04b6b798b4b12f6cb162865fbbc5dd350b084c6 | Alex Touchet | 2022-07-05T15:56:50 | cargo: use SPDX license format
Closes #106 | diff --git a/bench/Cargo.toml b/bench/Cargo.toml
index 5220235..c4f9bdb 100644
--- a/bench/Cargo.toml
+++ b/bench/Cargo.toml
@@ -6,7 +6,7 @@ authors = ["Andrew Gallant <jamslam@gmail.com>"]
description = "Criterion benchmark suite for bstr."
homepage = "https://github.com/BurntSushi/bstr"
repository = "https://githu... | 1 | 1 | 1 |
a4cc90dfedc85233a1ece00438b59effd6a2fa9d | Andrew Gallant | 2021-05-01T13:23:23 | cleanup: remove unnecessary 'allow' directives
I probably added these a while ago during some work and forgot to remove
them. | diff --git a/examples/graphemes-std.rs b/examples/graphemes-std.rs
index 12abdfd..647739d 100644
--- a/examples/graphemes-std.rs
+++ b/examples/graphemes-std.rs
@@ -16,8 +16,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.take(10)
.last()
.unwrap_or(line.len());
- #[allow(d... | 3 | 1 | 5 |
f8175601aca2088422877e59ca29c519a1f2a4f1 | Andrew Gallant | 2021-05-01T13:07:55 | bench: update to Criterion 0.3.4 | diff --git a/bench/Cargo.toml b/bench/Cargo.toml
index 75c691a..5220235 100644
--- a/bench/Cargo.toml
+++ b/bench/Cargo.toml
@@ -18,7 +18,7 @@ harness = false
path = "src/bench.rs"
[dependencies]
-criterion = "0.3.0"
+criterion = "0.3.4"
bstr = { version = "*", path = ".." }
# For comparisons.
unicode-segmentati... | 2 | 4 | 5 |
aacde12eb72fcac86460f82fc7d24baa2579f724 | Andrew Gallant | 2021-05-01T12:47:16 | fmt: run 'cargo fmt --all' | diff --git a/bench/src/bench.rs b/bench/src/bench.rs
index 3217d0d..9783f3d 100644
--- a/bench/src/bench.rs
+++ b/bench/src/bench.rs
@@ -1,8 +1,6 @@
#[macro_use]
extern crate criterion;
-
-
use bstr::{ByteSlice, B};
use criterion::{Bencher, Criterion, Throughput};
diff --git a/examples/graphemes-std.rs b/exampl... | 9 | 5 | 19 |
525738baa51c57c487040cde3547ca300c108635 | Andrew Gallant | 2021-05-01T12:36:10 | edition: run 'cargo fix --edition --edition-idioms' | diff --git a/bench/Cargo.toml b/bench/Cargo.toml
index 0191655..75c691a 100644
--- a/bench/Cargo.toml
+++ b/bench/Cargo.toml
@@ -20,9 +20,5 @@ path = "src/bench.rs"
[dependencies]
criterion = "0.3.0"
bstr = { version = "*", path = ".." }
-
# For comparisons.
unicode-segmentation = "1.2.1"
-
-[profile.release]
-deb... | 13 | 48 | 55 |
b2111b6bbf2c9a819fb1338aa81bd099874106a1 | Andrew Gallant | 2021-02-07T17:18:15 | impl: fix cow partialeq impl
Twas a silly mistake. One of the impls was comparing against itself,
which is obviously wrong. We fix it here and add a regression test.
We should probably add tests for other impls as well.
Fixes #82 | diff --git a/src/impls.rs b/src/impls.rs
index a291203..4cba48e 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -33,7 +33,7 @@ macro_rules! impl_partial_eq_cow {
#[inline]
fn eq(&self, other: &$lhs) -> bool {
let this: &[u8] = (&**other).as_ref();
- PartialEq::e... | 1 | 16 | 1 |
e9d337d3e54fa9547031b32ee55b999157bf56c0 | Andrew Gallant | 2021-02-07T17:17:24 | deps: upgrade to quickcheck 1.0 | diff --git a/Cargo.toml b/Cargo.toml
index 63388bc..20d1a26 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,7 +33,7 @@ regex-automata = { version = "0.1.5", default-features = false, optional = true
serde = { version = "1.0.85", default-features = false, optional = true }
[dev-dependencies]
-quickcheck = { version ... | 2 | 2 | 2 |
809c8b8237afd7c8c435268f72b3d2c03c6fcec5 | Andrew Gallant | 2020-10-18T15:34:56 | api: impl FusedIterator for CharIndices
Fixes #71 | diff --git a/src/utf8.rs b/src/utf8.rs
index 07f6104..2d4035d 100644
--- a/src/utf8.rs
+++ b/src/utf8.rs
@@ -225,6 +225,8 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> {
}
}
+impl<'a> ::core::iter::FusedIterator for CharIndices<'a> {}
+
/// An iterator over chunks of valid UTF-8 in a byte slice.
///
//... | 1 | 2 | 0 |
eafb4951c651c4b4eab94621c259f80b217803ee | Andrew Gallant | 2020-10-18T15:32:19 | impl: fix replacement codepoint handling in Debug impl
Previously, if an actual replacement codepoint was found in UTF-8, it
would print the UTF-8 encoding of the replacement codepoint instead of
the replacement codepoint itself. This is because the replacement
codepoint is used as a sentinel to determine whether inva... | diff --git a/src/impls.rs b/src/impls.rs
index fa3d114..c7d0be3 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -378,8 +378,13 @@ mod bstr {
match ch {
'\0' => write!(f, "\\0")?,
'\u{FFFD}' => {
- for &b in self[s..e].as_bytes() {
- ... | 1 | 19 | 3 |
8e2041ed5481078f25635dd7989a96abd87721ce | Paul Colomiets | 2020-06-11T13:33:05 | impl: improve Debug impl for BStr
Previously, any non-printable Unicode scalar value would get printed
using the '\u{...}' syntax. While not horrible, it's a bit weird to
do this for ASCII characters and especially for the NUL and various
whitespace characters. So this commit tweaks the Debug impl for BStr to
handle t... | diff --git a/src/impls.rs b/src/impls.rs
index 9aa80c9..fa3d114 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -375,12 +375,24 @@ mod bstr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "\"")?;
for (s, e, ch) in self.char_indices() {
- if ch == '\u{... | 1 | 26 | 5 |
16e782a7291a7f357ce4bfbf6d2155d65483e705 | Erik Zscheile | 2020-06-17T15:14:20 | api: add as_slice, size_hint and FusedIterator to Bytes
Fixes #61, Closes #62 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index f42d1a7..fa08190 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -5,12 +5,7 @@ use std::ffi::OsStr;
#[cfg(feature = "std")]
use std::path::Path;
-use core::cmp;
-use core::ops;
-use core::ptr;
-use core::slice;
-use core::str;
-
+use core::{cmp, iter, o... | 1 | 18 | 6 |
06295eea6d66db8539e15daccd658157fe24e0fc | CAD97 | 2020-07-10T18:53:09 | api: add From impls between Box<[u8]> and Box<BStr>
Fixes #66, Closes #67 | diff --git a/src/bstr.rs b/src/bstr.rs
index e95d931..1e3c91b 100644
--- a/src/bstr.rs
+++ b/src/bstr.rs
@@ -55,6 +55,18 @@ impl BStr {
unsafe { mem::transmute(slice) }
}
+ #[inline]
+ #[cfg(feature = "std")]
+ pub(crate) fn from_boxed_bytes(slice: Box<[u8]>) -> Box<BStr> {
+ unsafe { Bo... | 2 | 28 | 0 |
bad9e087fe88cbf04bf3d5f0111165df1460897f | Mara Bos | 2020-07-26T14:33:46 | api: add Utf8Chunk::incomplete method
This makes it possible to easily tell whether a particular chunk either
contains invalid UTF-8 or possibly contains a prefix of valid UTF-8.
This is useful in the context of processing streams.
Closes #68 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index a238f0c..f42d1a7 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -1724,8 +1724,8 @@ pub trait ByteSlice: Sealed {
///
/// # Examples
///
- /// This example shows how the `std::fmt::Display` implementation is
- /// written for the `BStr`... | 2 | 122 | 5 |
acc45f1bbd96ba7145249ab38d62f7588a4ede76 | GrayJack | 2020-08-03T22:57:33 | impl: support formatting alignment
This adds support for the various'{:5}' syntaxes defined by std::fmt. We
ended up having to re-roll it instead of using std's facilities because
we're working with byte slices and not &str. It would be simple to just
lossily convert a BStr into a String, but this would invalidate the... | diff --git a/src/impls.rs b/src/impls.rs
index 375e5be..2afc7d6 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -314,13 +314,59 @@ mod bstr {
impl fmt::Display for BStr {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- for chunk in self.utf8_chunks() {
- ... | 1 | 160 | 5 |
87a39778af5036b02ecb8905022acb6a34668cc8 | Todd Mortimer | 2020-08-22T16:09:19 | doc: improve example for trim_end_with
This makes the example illustrate the function.
Closes #74 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 4daa192..a238f0c 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -2225,7 +2225,7 @@ pub trait ByteSlice: Sealed {
/// ```
/// use bstr::{B, ByteSlice};
///
- /// let s = b"123foo5bar";
+ /// let s = b"123foo5bar789";
/// assert_eq!... | 1 | 1 | 1 |
8e659921312830b91d2a48aafa36fb1a49cba5bc | Mara Bos | 2020-10-18T13:14:32 | impl: improve ByteVec::into_string_lossy
It now re-uses to_str_lossy() (which is more efficient than looping
over v.chars() like this did), and no longer allocates in the case
where it was already valid utf-8.
Closes #76 | diff --git a/src/ext_vec.rs b/src/ext_vec.rs
index 9792c38..6f6db56 100644
--- a/src/ext_vec.rs
+++ b/src/ext_vec.rs
@@ -425,15 +425,14 @@ pub trait ByteVec: Sealed {
where
Self: Sized,
{
- let v = self.as_vec();
- if let Ok(allutf8) = v.to_str() {
- return allutf8.to_string(... | 1 | 7 | 8 |
ff3b24f5bd5808fe5a0522c93f28b63fb75f5f67 | Ryan Lopopolo | 2020-03-20T15:51:20 | api: add missing #[inline] annotations
Some extension functions, notably `ByteVec::into_string_unchecked` and
`ByteSlice::to_str_unchecked`, were not annotated as `#[inline]`. Since
you likely care about performance if you are using these converters, add
a few `#[inline]` annotations.
Closes #51 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 6e609b9..4daa192 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -125,6 +125,7 @@ pub trait ByteSlice: Sealed {
///
/// println!("{:?}", b"foo\xFFbar".as_bstr());
/// ```
+ #[inline]
fn as_bstr(&self) -> &BStr {
BStr::new(sel... | 2 | 5 | 0 |
881d1055f6eff94c9f1cd216aea860e4e7c764df | flyingcanoe | 2020-03-16T15:28:57 | utf8: add basic notes about safety
Fixes #47, Closes #48 | diff --git a/src/utf8.rs b/src/utf8.rs
index 4862d0c..5550291 100644
--- a/src/utf8.rs
+++ b/src/utf8.rs
@@ -42,8 +42,10 @@ use ext_slice::ByteSlice;
const ACCEPT: usize = 12;
const REJECT: usize = 0;
+/// SAFETY: The decode below function relies on the correctness of these
+/// equivalence classes.
#[cfg_attr(rus... | 1 | 9 | 3 |
8b26a9f224496ba460fabaf813033a3075be6946 | Thomas Hurst | 2020-02-28T05:17:45 | api: add byte record oriented IO functions
This mirrors the line iterating methods, but permits the caller to
specify an arbitrary terminator.
Closes #41 | diff --git a/src/io.rs b/src/io.rs
index f68a499..f2b4452 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -56,6 +56,49 @@ pub trait BufReadExt: io::BufRead {
ByteLines { buf: self }
}
+ /// Returns an iterator over byte-terminated records of this reader, where
+ /// each record is represented as a byte ... | 1 | 214 | 19 |
c9e0e737c6e10830632eee3edbdbf4ff618d9e6d | Andrew Gallant | 2020-05-10T12:22:33 | utf8: clarify is_leading_utf8_byte
It turns out that this returns true not just if the byte is a leading
byte, but also if the byte never appears in any valid UTF-8 sequence.
Furthermore, this is OK based on how we're using the function. It's only
used in two places. The first place only ever calls it with valid UTF-8... | diff --git a/src/utf8.rs b/src/utf8.rs
index d859e36..4862d0c 100644
--- a/src/utf8.rs
+++ b/src/utf8.rs
@@ -481,7 +481,7 @@ pub fn validate(slice: &[u8]) -> Result<(), Utf8Error> {
// code unit sequence. To do this, we simply locate the last leading
// byte that occurs before rejected_at.
le... | 1 | 23 | 4 |
2cfc51cbe6bb97c6481e6a2164e932b4824edc4c | Andrew Gallant | 2020-02-16T16:35:49 | bench: update deps | diff --git a/bench/Cargo.lock b/bench/Cargo.lock
index a4a6fcd..86c49ee 100644
--- a/bench/Cargo.lock
+++ b/bench/Cargo.lock
@@ -1,74 +1,85 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
-name = "arrayvec"
-version = "0.4.11"
+name = "anyhow"
+version = "1.0... | 1 | 326 | 181 |
aed424a778f43373824232e242e4f7894ba221f1 | Sebastian Dröge | 2020-02-04T22:40:42 | api: fix splitn_str and rsplitn_str
Don't return an empty last item from splitn_str/rsplitn_str if the
second to last item was already the remainder of the input.
For example "ab".splitn_str(2, ":") would return ["ab", ""] before this
change instead of the expected ["ab"].
Fixes #38 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index ce83ab7..6e609b9 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -1324,6 +1324,9 @@ pub trait ByteSlice: Sealed {
/// let x: Vec<_> = b"abcXdef".splitn_str(1, "X").collect();
/// assert_eq!(x, vec![B("abcXdef")]);
///
+ /// let x: Vec<_> =... | 1 | 8 | 2 |
eb2c93d41518f43196af1020c6003b563d077f5c | Erick Tryzelaar | 2020-01-21T21:14:36 | cargo: exclude .github from the packages
PR #32 | diff --git a/Cargo.toml b/Cargo.toml
index 32b83a9..5873a21 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ readme = "README.md"
keywords = ["string", "str", "byte", "bytes", "text"]
license = "MIT OR Apache-2.0"
categories = ["text-processing", "encoding"]
-exclude = ["/ci/*", "/.travis.yml", "/appveyor.... | 1 | 1 | 1 |
62c0b3e654546919246fa2fc2757afcf435be85b | Mara Bos | 2019-10-10T20:10:23 | impl: make Display more efficient in the non-UTF-8 case
It now prints whole chunks of valid UTF-8 at once, only stopping at
the places where the replacement character needs to appear, instead of
writing each character separately.
Closes #24 | diff --git a/src/impls.rs b/src/impls.rs
index 81599b0..375e5be 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -314,11 +314,11 @@ mod bstr {
impl fmt::Display for BStr {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- if let Ok(allutf8) = self.to_str() {
- ... | 1 | 5 | 5 |
baf456077bebf0a5c6b931339dc1758fb3e949af | Mara Bos | 2019-10-10T20:09:42 | api: Add ByteSlice::utf8_chunks
This new method permits efficiently traversing valid UTF-8 chunks in a
byte string.
Ref PR #24 | diff --git a/src/ascii.rs b/src/ascii.rs
index 090c51b..bb2b679 100644
--- a/src/ascii.rs
+++ b/src/ascii.rs
@@ -298,9 +298,7 @@ mod tests {
for i in 0..517 {
for align in 0..65 {
let mut s = "a".repeat(i);
- s.push_str(
- "☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃... | 4 | 151 | 16 |
801e4af97afd4a37de3cbad23816c91e39a5e3b4 | Andrew Gallant | 2020-01-10T18:03:42 | api: make BStr repr(transparent)
Since we are transmuting a &[u8] to a &BStr, we technically need an ABI
guarantee that BStr is the same as [u8]. repr(transparent) gives us
that.
Fixes #26 | diff --git a/src/bstr.rs b/src/bstr.rs
index fd8f8b3..e95d931 100644
--- a/src/bstr.rs
+++ b/src/bstr.rs
@@ -27,6 +27,7 @@ use core::mem;
/// converted to a `str`. Invalid UTF-8 bytes are substituted with the Unicode
/// replacement codepoint, which looks like this: �.
#[derive(Hash)]
+#[repr(transparent)]
pub stru... | 1 | 1 | 0 |
11d0792665defa3bffce6646ac9e12a2f740d75d | Andrew Gallant | 2019-08-30T13:39:46 | doc: add note about constructor methods
All of the examples are already correct with respect to this bugaboo,
but we add an explicit call-out for it to cover our bases.
Fixes #14 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 35f5ed0..bf7d910 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -94,7 +94,7 @@ impl ByteSlice for [u8] {
pub trait Sealed {}
impl Sealed for [u8] {}
-/// A trait that extends a slice of bytes with string oriented methods.
+/// A trait that extends `&[u... | 2 | 14 | 3 |
66dee497c8da16f397c1d0952e58dadf04b66b5c | Thomas Hurst | 2019-08-17T03:15:24 | perf: minimise copying in for_byte_line
Lend out slices of complete strings from the internal buffer, and only
fall back on read_until for fragments at the end.
Because of the increased complexity, we add a number of tests in
addition to the existing doc tests.
This appears to improve performance by about 2x:
$... | diff --git a/src/io.rs b/src/io.rs
index 4ba67c7..f68a499 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -92,20 +92,14 @@ pub trait BufReadExt: io::BufRead {
/// assert_eq!(lines[2], "dolor".as_bytes());
/// # Ok(()) }; example().unwrap()
/// ```
- fn for_byte_line<F>(mut self, mut for_each_line: F) -> io:... | 1 | 127 | 13 |
b5cb44453caebccb9d6284d0e721771fba84cb54 | Andrew Gallant | 2019-08-30T13:06:36 | bench: add benchmark for for_byte_line | diff --git a/bench/src/bench.rs b/bench/src/bench.rs
index 1845dfc..f610a50 100644
--- a/bench/src/bench.rs
+++ b/bench/src/bench.rs
@@ -244,6 +244,24 @@ fn sentences(c: &mut Criterion) {
}
}
+fn byte_lines(c: &mut Criterion) {
+ use bstr::io::BufReadExt;
+
+ let corpus = SUBTITLE_EN_HUGE;
+ define(c, ... | 1 | 30 | 11 |
c5d6aa5c97b4b624bf1aac796b88bb137f5a2a5e | Andrew Gallant | 2019-08-30T12:45:19 | bench/deps: update everything | diff --git a/bench/Cargo.lock b/bench/Cargo.lock
index ef2667d..7122049 100644
--- a/bench/Cargo.lock
+++ b/bench/Cargo.lock
@@ -2,7 +2,7 @@
# It is not intended for manual editing.
[[package]]
name = "arrayvec"
-version = "0.4.10"
+version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"... | 1 | 143 | 137 |
c14be45989d0af804866b6edfe54b5785016eff6 | Andrew Gallant | 2019-08-11T14:23:58 | fmt: use rustfmt +stable | diff --git a/src/ext_vec.rs b/src/ext_vec.rs
index 5effba8..e48a5da 100644
--- a/src/ext_vec.rs
+++ b/src/ext_vec.rs
@@ -384,9 +384,7 @@ pub trait ByteVec: Sealed {
Self: Sized,
{
match utf8::validate(self.as_vec()) {
- Err(err) => {
- Err(FromUtf8Error { original: self.... | 1 | 1 | 3 |
c716c88e6f2f12311e58af01a9fbbefe4d2a8fd8 | Andrew Gallant | 2019-08-11T14:00:11 | api: inline trivial definitions | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index e86db2e..35f5ed0 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -78,9 +78,12 @@ pub fn B<'a, B: ?Sized + AsRef<[u8]>>(bytes: &'a B) -> &'a [u8] {
}
impl ByteSlice for [u8] {
+ #[inline]
fn as_bytes(&self) -> &[u8] {
self
}
+
+ ... | 2 | 10 | 2 |
94a82fece29f03e598f4ba00a0fa68603ce130d3 | Andrew Gallant | 2019-07-30T23:53:47 | api: re-arrange byteset methods
Namely, move them below the primary substring search methods, since they
are a bit more niche. | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index f5f4a45..e86db2e 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -649,154 +649,6 @@ pub trait ByteSlice: Sealed {
self.as_bytes().ends_with(suffix.as_ref())
}
- /// Returns the index of the first occurrence of any of the bytes in the
- ... | 1 | 148 | 148 |
56fcd34325a3b4639d181903cecb12c9d7c26486 | Thom Chiovoloni | 2019-07-24T23:56:36 | api: add find_non_ascii_byte
This just exposes an internal method that also happens
to be generally useful. Namely, the routine is heavily
optimized.
PR #19 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 1cb93c4..f5f4a45 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -2833,6 +2833,31 @@ pub trait ByteSlice: Sealed {
bytes.get(bytes.len().saturating_sub(1)).map(|&b| b)
}
+ /// Returns the index of the first non-ASCII byte in this byte str... | 1 | 25 | 0 |
3e487ed6efb14ad293bcd14c60a1862782a19544 | Andrew Gallant | 2019-07-22T22:03:06 | docs: fix a couple small errors
Fixes #17 | diff --git a/src/ext_slice.rs b/src/ext_slice.rs
index 7388793..1cb93c4 100644
--- a/src/ext_slice.rs
+++ b/src/ext_slice.rs
@@ -1073,7 +1073,9 @@ pub trait ByteSlice: Sealed {
/// Returns an iterator over the fields in a byte string, separated by
/// contiguous codepoints satisfying the given predicate.
... | 1 | 4 | 3 |
110222db6fef810142729f08ce575d2072120b14 | Thom Chiovoloni | 2019-07-21T00:17:06 | api: add functions for searching bytesets
This provides APIs for finding a byte in a set, or the inverse, finding
a byte not in a particular set.
PR #15 | diff --git a/bench/Cargo.lock b/bench/Cargo.lock
index 9f04ef7..ef2667d 100644
--- a/bench/Cargo.lock
+++ b/bench/Cargo.lock
@@ -30,7 +30,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bstr"
-version = "0.1.4"
+version = "0.2.2"
dependencies = [
"lazy_static 1.3.0 (regi... | 7 | 696 | 3 |
fcfcec610894766f7c506f1a6ffc284aa9cf3647 | Andrew Gallant | 2019-07-20T20:16:55 | fmt: update to latest rustfmt | diff --git a/src/ascii.rs b/src/ascii.rs
index 090c51b..bb2b679 100644
--- a/src/ascii.rs
+++ b/src/ascii.rs
@@ -298,9 +298,7 @@ mod tests {
for i in 0..517 {
for align in 0..65 {
let mut s = "a".repeat(i);
- s.push_str(
- "☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃... | 2 | 4 | 14 |
e02d02aa7b9e206dcba3a15ab5a65dd470dbb7ec | Andrew Gallant | 2019-07-14T12:06:53 | api: add Default impl for BString/BStr
While we're trying to keep the BString/BStr APIs fairly spartan for now
(until more details arise about their use cases), it's generally good to
load them up with as many trait impls as we can. Default is particularly
helpful since it enables `derive(Default)` for types that cont... | diff --git a/src/impls.rs b/src/impls.rs
index 207fd1c..087e70b 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -144,6 +144,12 @@ mod bstring {
}
}
+ impl Default for BString {
+ fn default() -> BString {
+ BString::from(vec![])
+ }
+ }
+
impl<'a> From<&'a [u8]> for B... | 1 | 18 | 0 |
acb69394359a34ca2f51cd6b44e0d754b27c626b | ggriffiniii | 2019-05-24T16:58:44 | api: Bytes should implement Clone
PR #6 | diff --git a/src/bstr.rs b/src/bstr.rs
index 0bed001..b1bc2f9 100644
--- a/src/bstr.rs
+++ b/src/bstr.rs
@@ -3555,7 +3555,7 @@ impl<'a> Iterator for FindReverse<'a> {
/// An iterator over the bytes in a byte string.
///
/// `'a` is the lifetime of the byte string being traversed.
-#[derive(Debug)]
+#[derive(Clone, D... | 1 | 1 | 1 |
10ccb4f773dab8214d25120fb42f7ac5b5c289a9 | ggriffiniii | 2019-05-24T10:40:00 | impls: add From implementations for Cow<'_, BStr>
PR #7 | diff --git a/src/impls.rs b/src/impls.rs
index 1129f18..614139b 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -60,7 +60,7 @@ macro_rules! impl_partial_ord {
#[cfg(feature = "std")]
mod bstring {
- use std::borrow::{Borrow, ToOwned};
+ use std::borrow::{Borrow, Cow, ToOwned};
use std::cmp::Ordering;
... | 1 | 16 | 1 |
5ba421e695f9b06f04304f4be11c94653530e198 | Andrew Gallant | 2019-05-12T15:10:43 | api: add inline annotations
These were showing up on a profile. | diff --git a/src/bstr.rs b/src/bstr.rs
index 6957bec..0bed001 100644
--- a/src/bstr.rs
+++ b/src/bstr.rs
@@ -354,6 +354,7 @@ impl BStr {
#[cfg(feature = "std")]
#[cfg(unix)]
+ #[inline]
fn from_os_str_imp(os_str: &OsStr) -> Option<&BStr> {
use std::os::unix::ffi::OsStrExt;
@@ -362,6 +363,... | 2 | 18 | 0 |
0a752f2bc6a7e150e2b09be1bc7bba83e8cc9d9a | Andrew Gallant | 2019-04-06T02:05:26 | search: tweak prefilter settings
It turns out that so long as we're skipping a small fixed number of
bytes, then the prefilter is still good to use. I found this when
testing a search of a hash in a large random collection of hashes. This
is good for a 2x speedup without materially impacting existing
benchmarks.
We a... | diff --git a/src/search/prefilter.rs b/src/search/prefilter.rs
index a558a0d..4331542 100644
--- a/src/search/prefilter.rs
+++ b/src/search/prefilter.rs
@@ -29,15 +29,15 @@ pub struct PrefilterState {
impl PrefilterState {
/// The minimum number of skip attempts to try before considering whether
/// a prefil... | 1 | 8 | 10 |
02786816813e14c2c69f41d170e5d41fd6b6557a | Andrew Gallant | 2019-04-06T00:24:47 | perf: liberally apply #[inline]
In performance profiling, most of these functions aren't being inline
across crate boundaries, which is bad, since most functions are pretty
tiny. As I understand it, in order for non-generic functions to get
inlined across crate boundaries, an #[inline] annotation is required.
Some fun... | diff --git a/src/bstr.rs b/src/bstr.rs
index a772d25..6957bec 100644
--- a/src/bstr.rs
+++ b/src/bstr.rs
@@ -75,6 +75,7 @@ use utf8::{self, Chars, CharIndices, Utf8Error};
/// Notice that this also lets you mix and match both string literals and byte
/// string literals. This can be quite convenient!
#[allow(non_sna... | 7 | 184 | 0 |
abea3e1aecd0713e9f99bb8c7539b102424c85d6 | Andrew Gallant | 2019-04-05T20:25:40 | api: deprecated pop, add pop_char and pop_byte
This mirrors the push_char and push_byte APIs.
Fixes #2 | diff --git a/src/bstring.rs b/src/bstring.rs
index 2c037ac..bcd67ca 100644
--- a/src/bstring.rs
+++ b/src/bstring.rs
@@ -961,9 +961,91 @@ impl BString {
/// Removes the last codepoint from this `BString` and returns it.
///
- /// If this string is empty, then `None` is returned. If the last bytes
- //... | 2 | 89 | 12 |
d2b5053c5d0a98385fda756858e2d8191e8f14bf | Andrew Gallant | 2019-04-05T20:11:58 | api: add path/os_str conversion routines
This commit adds the full matrix of filepath<->bstr and osstr<->bstr
conversion routines. This should make it much nicer to deal with file
paths without sacrificing correctness on Unix. | diff --git a/src/bstr.rs b/src/bstr.rs
index fc0eacc..a772d25 100644
--- a/src/bstr.rs
+++ b/src/bstr.rs
@@ -1,8 +1,13 @@
#[cfg(feature = "std")]
use std::borrow::Cow;
-use core::cmp;
+#[cfg(feature = "std")]
+use std::ffi::OsStr;
#[cfg(feature = "std")]
use std::iter;
+#[cfg(feature = "std")]
+use std::path::Path;... | 3 | 564 | 1 |
7d02250b8c5ca7f08324e9502b39236b58add649 | Andrew Gallant | 2019-04-05T20:11:03 | impl: add Cow impls for PartialEq | diff --git a/src/impls.rs b/src/impls.rs
index 5e2f01d..b6ae079 100644
--- a/src/impls.rs
+++ b/src/impls.rs
@@ -18,6 +18,26 @@ macro_rules! impl_partial_eq {
}
}
+macro_rules! impl_partial_eq_cow {
+ ($lhs:ty, $rhs:ty) => {
+ impl<'a, 'b> PartialEq<$rhs> for $lhs {
+ #[inline]
+ ... | 1 | 29 | 0 |
26889c3b5bfd922a54567afe28896e527317af93 | Aleksey Kladov | 2019-04-02T10:29:49 | doc: AsMut<[u8]> isn't impled for Strings
One can't *mutably* borrow bytes from a String, that could break
utf-8 invariant. | diff --git a/src/bstr.rs b/src/bstr.rs
index d9f146a..fc0eacc 100644
--- a/src/bstr.rs
+++ b/src/bstr.rs
@@ -166,7 +166,7 @@ impl BStr {
/// Create a mutable byte string slice from anything that can be borrowed
/// as a sequence of bytes. This includes, but is not limited to, `&mut
- /// Vec<u8>`, `&mut ... | 1 | 1 | 1 |
c64b3a812b117c31ec6329c2813867ec8c58d200 | Andrew Gallant | 2019-04-02T01:09:51 | examples: allow deprecated use of trim_right
So that we can (easily) run tests on Rust 1.28 (our MSRV). | diff --git a/examples/graphemes-std.rs b/examples/graphemes-std.rs
index ecace8f..da3faf3 100644
--- a/examples/graphemes-std.rs
+++ b/examples/graphemes-std.rs
@@ -18,6 +18,7 @@ fn main() -> Result<(), Box<Error>> {
.take(10)
.last()
.unwrap_or(line.len());
+ #[allow(depre... | 1 | 1 | 0 |
d91de3cc5c75540476e04778be40fa3038ea13cb | Andrew Gallant | 2019-04-02T01:09:25 | deps: drop deps from quickcheck | diff --git a/Cargo.toml b/Cargo.toml
index 7bd9098..fc5a75d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,7 +33,7 @@ regex-automata = { version = "0.1.5", default-features = false, optional = true
serde = { version = "1.0.85", default-features = false, optional = true }
[dev-dependencies]
-quickcheck = "0.8.1"
+q... | 1 | 1 | 1 |
7faae875e76ddc05feb24f2bc935532ebfe7fefc | Sebastian Thiel | 2026-01-19T07:18:12 | Thanks clippy (on Windows) | diff --git a/src/lib.rs b/src/lib.rs
index 3ccaa32..4064132 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -322,6 +322,7 @@ impl IntoResult<io::Result<()>> for io::Result<std::process::ExitStatus> {
trait CommandExt {
fn status_without_output(&mut self) -> io::Result<std::process::ExitStatus>;
+ #[cfg_attr(feat... | 2 | 8 | 12 |
5604cee4aae32689e3e648a520f76797b49988e4 | Chris Denton | 2026-01-19T06:40:36 | Use absolute instead of canonicalize | diff --git a/src/windows.rs b/src/windows.rs
index f9f864b..6a1d454 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -69,8 +69,8 @@ pub fn that_detached<T: AsRef<OsStr>>(path: T) -> std::io::Result<()> {
#[cfg(feature = "shellexecute-on-windows")]
fn shell_open_folder(path: &OsStr) -> Result<(), std::io::Error> ... | 1 | 2 | 2 |
abcd0f4810cbcdee4d80dba01a6474ad711efa61 | Tony | 2025-11-17T15:18:12 | fix(windows): pass canonicalized path to `ILCreateFromPathW` | diff --git a/src/windows.rs b/src/windows.rs
index da608a3..f9f864b 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -38,17 +38,11 @@ fn wrap_in_quotes<T: AsRef<OsStr>>(path: T) -> OsString {
#[cfg(feature = "shellexecute-on-windows")]
pub fn that_detached<T: AsRef<OsStr>>(path: T) -> std::io::Result<()> {
- ... | 1 | 18 | 9 |
314d80ac36650f3ff57d62596513e1dcda4870fb | Bryan A. Jones | 2025-05-30T14:57:54 | clean: remove whitespace. | diff --git a/src/lib.rs b/src/lib.rs
index 4b1a09c..3ccaa32 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,7 +2,7 @@
//!
//! It is expected that `http:` and `https:` URLs will open in a web browser, although the desktop configuration may override this.
//! The choice of application for opening other path types is hi... | 1 | 1 | 1 |
c452a8c4e56c3726431d8a4a77ad910bc8ae3ecb | amrbashir | 2025-01-05T14:21:23 | fix(windows): fix `that_detached` for UNC path of a directory
closes #106
This PR also fallsback to `ShellExecuteExW` if `SHOpenFolderAndSelectItems` fails | diff --git a/Cargo.toml b/Cargo.toml
index 3b1d3a5..58750dd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,7 +20,7 @@ rust-version = "1.62"
##
## There may be other side-effects that when comparing to the command-based
## opening of paths, which is why this feature is opt-in.
-shellexecute-on-windows = []
+shellexe... | 2 | 27 | 7 |
7595da7d655e910f3cb9d26b96d3947f2acf2522 | Tony | 2024-11-14T15:51:44 | fix: use SHOpenFolderAndSelectItems for folders
To respect 'expand to open folder' setting
Fixes #103 | diff --git a/src/windows.rs b/src/windows.rs
index e231730..66431a8 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -43,17 +43,18 @@ pub fn that_detached<T: AsRef<OsStr>>(path: T) -> std::io::Result<()> {
let path = wide(path);
- let (verb, class) = if is_dir {
- (ffi::EXPLORE, ffi::FOLDER)
- ... | 1 | 62 | 12 |
58142a695d50460e439f85be3f0bc010936520e6 | Pino Toscano | 2024-07-10T03:32:22 | feat: add GNU/Hurd support
Handle it like most of the other Unix platforms (e.g. Linux, BSDs, etc). | diff --git a/Cargo.toml b/Cargo.toml
index 04a84e6..8a3e811 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,7 +30,7 @@ name = "open"
[target.'cfg(all(unix, not(macos)))'.dependencies]
pathdiff = "0.2.0"
-[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd", target_os = "dragonfly", tar... | 2 | 7 | 4 |
b41421579aa68b484d57814acd2ef33e5b1b9b5a | Kai Luo | 2024-07-02T03:02:51 | Add AIX support | diff --git a/Cargo.toml b/Cargo.toml
index 360dd61..e469c06 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,7 +30,7 @@ name = "open"
[target.'cfg(all(unix, not(macos)))'.dependencies]
pathdiff = "0.2.0"
-[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd", target_os = "dragonfly", tar... | 2 | 7 | 4 |
df28e8bdce30cd1a8e930c947566edfd8835cef8 | Eugene Hauptmann | 2024-05-29T22:54:08 | added visionos support | diff --git a/src/lib.rs b/src/lib.rs
index 2c6a43c..8ee987f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -75,6 +75,9 @@ use macos as os;
#[cfg(target_os = "ios")]
use ios as os;
+#[cfg(target_os = "visionos")]
+use ios as os;
+
#[cfg(target_os = "haiku")]
use haiku as os;
@@ -103,6 +106,7 @@ use unix as os;
... | 1 | 7 | 0 |
c8840afb1550cef2c9897130c7d05b72bfd55d4a | amrbashir | 2024-05-16T18:01:08 | use cfg_attr | diff --git a/src/windows.rs b/src/windows.rs
index 506bb02..e231730 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -49,7 +49,6 @@ pub fn that_detached<T: AsRef<OsStr>>(path: T) -> std::io::Result<()> {
(std::ptr::null(), std::ptr::null())
};
-
let mut info = ffi::SHELLEXECUTEINFOW {
c... | 1 | 4 | 34 |
75c7ea085116502d4dae61bc752cb27e7663a914 | Amr Bashir | 2024-05-16T17:57:28 | Update src/windows.rs
Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com> | diff --git a/src/windows.rs b/src/windows.rs
index 4303681..506bb02 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -49,7 +49,6 @@ pub fn that_detached<T: AsRef<OsStr>>(path: T) -> std::io::Result<()> {
(std::ptr::null(), std::ptr::null())
};
- dbg!(verb, class);
let mut info = ffi::SHELLE... | 1 | 0 | 1 |
43d8d88a2d5949114cdebcc08a0aad68f2141e54 | amrbashir | 2024-05-16T02:56:49 | fix(windows): use `ShellExecuteExW` to avoid freeze when opening directories
ref: https://github.com/tauri-apps/plugins-workspace/issues/1137
ref: https://github.com/tauri-apps/tauri/issues/9624 | diff --git a/src/windows.rs b/src/windows.rs
index 1f4381e..4303681 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -38,18 +38,29 @@ fn wrap_in_quotes<T: AsRef<OsStr>>(path: T) -> OsString {
#[cfg(feature = "shellexecute-on-windows")]
pub fn that_detached<T: AsRef<OsStr>>(path: T) -> std::io::Result<()> {
+ ... | 1 | 106 | 53 |
7652a3016e3b243604f38d40eab6097c2d816fde | Sebastian Thiel | 2024-03-09T07:44:28 | clarify docs of `shellexecute-on-windows` feature (#94) | diff --git a/Cargo.toml b/Cargo.toml
index 80adff3..ed4194e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,14 +13,13 @@ include = ["src/**/*", "LICENSE.md", "README.md", "changelog.md"]
rust-version = "1.62"
[features]
-## If enabled, link to `shell32` on Windows and use `ShellExecuteW` intead of a command invocat... | 1 | 4 | 5 |
2a62e84a234274b53cb77ffcef4ad76630ba7c2f | amrbashir | 2024-03-07T16:57:48 | fix(windows): link using "system" ABI | diff --git a/src/windows.rs b/src/windows.rs
index 4784884..1f4381e 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -121,8 +121,7 @@ mod ffi {
/// Null-terminated UTF-16 encoding of `open`.
pub const OPEN: *const u16 = [111, 112, 101, 110, 0].as_ptr();
- #[link(name = "Shell32")]
- extern "C" {
... | 1 | 2 | 3 |
4506b2f8ac51579932b76884a11133ce5c49c21f | amrbashir | 2024-02-29T21:03:57 | split into two functions for better readability | diff --git a/src/windows.rs b/src/windows.rs
index 2bd22ef..2977c78 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -40,24 +40,34 @@ fn wrap_in_quotes<T: AsRef<OsStr>>(path: T) -> OsString {
}
pub fn that_detached<T: AsRef<OsStr>>(path: T) -> std::io::Result<()> {
- detached(path, None::<&str>)
-}
+ let p... | 1 | 23 | 13 |
191cb0e2201c911d1bf0df3ba03062c6d9b6e738 | amrbashir | 2024-02-29T20:58:59 | feat: use `ShellExecuteW` for detached spawning on Windows
ref: https://github.com/Byron/open-rs/issues/90 & https://github.com/tauri-apps/plugins-workspace/issues/1003 | diff --git a/src/lib.rs b/src/lib.rs
index f21897b..9afcd8c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -237,16 +237,24 @@ pub fn with_in_background<T: AsRef<OsStr>>(
///
/// See documentation of [`that()`] for more details.
pub fn that_detached(path: impl AsRef<OsStr>) -> io::Result<()> {
- let mut last_err = No... | 2 | 106 | 9 |
a583658a2f2cfea64c3be6e12cef159f5cbc7fbf | Jeremy Soller | 2024-02-28T03:26:03 | redox: use PATH to find launcher
Redox has moved the launcher from /ui/bin to /usr/bin. Just use the PATH to locate it, so any future changes in location don't break this crate. | diff --git a/src/redox.rs b/src/redox.rs
index 8fab343..1a3e017 100644
--- a/src/redox.rs
+++ b/src/redox.rs
@@ -1,7 +1,7 @@
use std::{ffi::OsStr, process::Command};
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
- let mut cmd = Command::new("/ui/bin/launcher");
+ let mut cmd = Command::new("laun... | 1 | 1 | 1 |
e1b74d8e171ce63ddf4cad212a94b8238ae66be7 | Albert Dong | 2023-11-22T01:25:39 | Wrap provided app in quotes on Windows | diff --git a/src/windows.rs b/src/windows.rs
index e9f9aee..74ced51 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -22,7 +22,7 @@ pub fn with_command<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> Command
cmd.arg("/c")
.arg("start")
.raw_arg("\"\"")
- .raw_arg(app.into())
+ ... | 1 | 1 | 1 |
b5528b60d49f4dd48449d9ff5b75edbea71ce248 | Sebastian Thiel | 2023-06-25T07:08:25 | cleanup `main` program to support `--with` on all platforms.
Technically this is a breaking change as the way it communicates now looks different,
and error handling is different as well. | diff --git a/src/main.rs b/src/main.rs
index a7eee23..245f2db 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,34 +1,23 @@
-use std::{env, process};
+use std::env;
-fn main() {
- let path_or_url = match env::args().nth(1) {
+fn main() -> Result<(), Box<dyn std::error::Error>> {
+ let mut args = env::args();
+ ... | 1 | 16 | 27 |
5607cd69f4f53aa02c67bccb60f7d4f9be6b74ea | ZhuXiaojie | 2023-06-25T03:02:51 | Fix open::with() on Windows. (#80) | diff --git a/src/main.rs b/src/main.rs
index 1992ea8..a7eee23 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,11 +9,21 @@ fn main() {
}
};
+ #[cfg(not(windows))]
let result = match std::env::var("OPEN_WITH").ok() {
Some(program) => open::with(&path_or_url, program),
None => op... | 2 | 12 | 0 |
659b8a0a6580fb89376daf27822fc08557ccf477 | Sebastian Thiel | 2023-06-21T19:12:15 | `open` application now reads `OPEN_WITH` environment variable to obtain the program to open with. (#80)
This is helpful when testing new features around the `with()` function. | diff --git a/src/main.rs b/src/main.rs
index eabef0d..1992ea8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,7 +9,12 @@ fn main() {
}
};
- match open::that(&path_or_url) {
+ let result = match std::env::var("OPEN_WITH").ok() {
+ Some(program) => open::with(&path_or_url, program),
+ ... | 1 | 6 | 1 |
7ad9cb373eb7e999f7e79705db891fd24a4d4bd2 | Amr Bashir | 2023-06-19T23:06:19 | feat: add `that_detached` and `with_detached`
ref: https://github.com/tauri-apps/tauri/issues/6849 | diff --git a/Cargo.toml b/Cargo.toml
index ab9435c..e5e8c64 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,3 +22,6 @@ pathdiff = "0.2.0"
[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd", target_os = "illumos", ta... | 2 | 69 | 1 |
323b8ea2aba9b0661bf3af6bd48ccef53197b0bf | Sebastian Thiel | 2023-05-24T07:33:52 | doc: Improve documentation about shortcomings particularly on console-only UNIX platforms. (#8)
Co-authored-by: Bart Massey <bart.massey@gmail.com> | diff --git a/src/lib.rs b/src/lib.rs
index ecce442..84c516e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,7 @@
-//! Use this library to open a path or URL using the program configured on the system in a non-blocking fashion.
+//! Use this library to open a given path or URL in some application, obeying the curren... | 1 | 19 | 1 |
4c31d9cb55a60881a84c81454c3f433b2c215809 | Jeremy Soller | 2023-04-26T17:27:54 | Add Redox support | diff --git a/src/lib.rs b/src/lib.rs
index 4907263..ecce442 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -78,6 +78,9 @@ use ios as os;
#[cfg(target_os = "haiku")]
use haiku as os;
+#[cfg(target_os = "redox")]
+use redox as os;
+
#[cfg(any(
target_os = "linux",
target_os = "android",
@@ -102,7 +105,8 @@ us... | 2 | 21 | 1 |
1912915cd541381a8184f574e13c3b31ba6f0a06 | Sebastian Thiel | 2023-04-16T07:43:48 | Only pull `is-wsl` on unix. | diff --git a/Cargo.toml b/Cargo.toml
index e254eb6..488d8f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,5 +20,5 @@ name = "open"
[target.'cfg(all(unix, not(macos)))'.dependencies]
pathdiff = "0.2.0"
-[dependencies]
+[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd", target_os = ... | 1 | 1 | 1 |
b150494e70cfea1fb6aec87d1100c4426d13a16a | Reilly Wood | 2023-04-16T06:07:20 | Check whether running in WSL before trying wslview | diff --git a/Cargo.toml b/Cargo.toml
index 1f47702..e254eb6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,3 +19,6 @@ name = "open"
[target.'cfg(all(unix, not(macos)))'.dependencies]
pathdiff = "0.2.0"
+
+[dependencies]
+is-wsl = "0.4.0"
diff --git a/src/unix.rs b/src/unix.rs
index c994e72..0e1fdb7 100644
--- a/sr... | 2 | 25 | 15 |
9048e63181626ca9c165f8e85682465bbb985554 | Reilly Wood | 2023-04-15T18:11:53 | Prioritize wslview so it's always launched when present | diff --git a/src/unix.rs b/src/unix.rs
index a283cf9..c994e72 100644
--- a/src/unix.rs
+++ b/src/unix.rs
@@ -1,4 +1,5 @@
use std::{
+ borrow::Borrow,
env,
ffi::{OsStr, OsString},
path::{Path, PathBuf},
@@ -8,11 +9,11 @@ use std::{
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
let ... | 1 | 2 | 1 |
bc75d847c6c89cdd835f4220d6a0ed9a6985b41e | Amr Bashir | 2023-03-20T16:21:55 | fix: hide the console window in Windows
ref: https://github.com/tauri-apps/tauri/issues/6438 | diff --git a/src/windows.rs b/src/windows.rs
index 4c4bf71..1fe7441 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -5,12 +5,15 @@ use std::{
use std::os::windows::process::CommandExt;
+const CREATE_NO_WINDOW: u32 = 0x08000000;
+
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
let mut cmd = C... | 1 | 6 | 2 |
9a1178a9d32c2b4da12cdb8542b3b36806825d7d | Sebastian Thiel | 2023-03-10T08:10:50 | refactor | diff --git a/src/windows.rs b/src/windows.rs
index e769a15..4c4bf71 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -10,7 +10,7 @@ pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
cmd.arg("/c")
.arg("start")
.raw_arg("\"\"")
- .raw_arg(wrap_in_quotes(path.as_ref()));
+ ... | 1 | 2 | 2 |
0cd6f98d0a97ac3ddcecefc5d33952e7632298a5 | Sebastian Thiel | 2023-03-10T08:06:03 | feat!: set minimal required Rust version of 1.62.
This version is motivated only when compiling on windows (but we can't differentiate that)
due to the recent addition of `CommandExt::raw_arg()`.
This might be a breaking change as previously there was no minimal supported Rust version. | diff --git a/Cargo.toml b/Cargo.toml
index 784f0eb..2126ae0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@ description = "Open a path or URL using the program configured on the system"
repository = "https://github.com/Byron/open-rs"
keywords = ["open", "xdg-open", "start", "launch"]
include = ["src/**/*"... | 1 | 1 | 0 |
e4856acd170cdea5b06a947c7e7e9cdd36f0b392 | Daniel Schlosser | 2023-03-09T19:37:01 | Fix Windows URL encoding for multiple query params
Previously, passing a URL with multiple query parameters on Windows would result in improper escaping, causing unexpected behavior when using it with "cmd /c". This commit addresses this issue by properly escaping all query parameters in the URL. Now, URLs with multip... | diff --git a/src/windows.rs b/src/windows.rs
index 2bd4db0..e769a15 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -1,13 +1,31 @@
-use std::{ffi::OsStr, process::Command};
+use std::{
+ ffi::{OsStr, OsString},
+ process::Command,
+};
+
+use std::os::windows::process::CommandExt;
pub fn commands<T: AsRef<O... | 1 | 21 | 3 |
7e2a9c645cd4ff5f86ece7cdc220e18c1b4ac1b5 | Sebastian Thiel | 2023-03-06T10:15:23 | doc: improve documentation around how to use the library. | diff --git a/src/lib.rs b/src/lib.rs
index a44e348..4907263 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,19 +5,37 @@
//! Open the given URL in the default web browser, without blocking.
//!
//! ```no_run
-//! open::that("http://rust-lang.org").unwrap();
+//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
... | 1 | 27 | 5 |
cb322bf72733a210bd41654bd3152f19dbb31059 | Sebastian Thiel | 2023-03-06T10:06:11 | modernize generics of API using `impl` instead of 'the other way'. | diff --git a/src/lib.rs b/src/lib.rs
index 6bdd834..a44e348 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -113,7 +113,7 @@ use std::{
///
/// Sometimes, depending on the platform and system configuration, launchers *can* block.
/// If you want to be sure they don't, use [`that_in_background()`] instead.
-pub fn that<T... | 1 | 5 | 5 |
2f6fb473c53538544d3693a6057049b2ccdee6e2 | Sebastian Thiel | 2023-03-06T10:04:26 | thanks clippy | diff --git a/src/lib.rs b/src/lib.rs
index ddd41e1..6bdd834 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -165,7 +165,7 @@ pub fn with<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> io::Result<()>
/// # Ok(())
/// # }
/// ```
-pub fn commands<'a, T: AsRef<OsStr>>(path: T) -> Vec<Command> {
+pub fn commands<T: As... | 1 | 2 | 2 |
66e0d7c295317aed27e89af8e323dde3b761c0e3 | Sebastian Thiel | 2023-03-06T09:45:35 | feat: `with_command()` to obtain the command that opens a program with a given application. | diff --git a/src/haiku.rs b/src/haiku.rs
index 7ffb4f2..2fbcd13 100644
--- a/src/haiku.rs
+++ b/src/haiku.rs
@@ -1,6 +1,4 @@
-use std::{ffi::OsStr, io, process::Command};
-
-use crate::{CommandExt, IntoResult};
+use std::{ffi::OsStr, process::Command};
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
... | 6 | 36 | 40 |
c2e0eb2d08b54472485bbc552e91043dbfb163bb | Sebastian Thiel | 2023-03-06T09:47:33 | refactor
Deduplicate | diff --git a/src/haiku.rs b/src/haiku.rs
index 4f7a599..7ffb4f2 100644
--- a/src/haiku.rs
+++ b/src/haiku.rs
@@ -8,11 +8,6 @@ pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
vec![cmd]
}
-pub fn that<T: AsRef<OsStr>>(path: T) -> io::Result<()> {
- let cmd = &mut commands(path)[0];
- cmd.status_... | 6 | 10 | 34 |
a501d65388562724471b5493fe54c88fe23df31e | Sebastian Thiel | 2023-03-06T09:27:57 | feat: improved error messages that will list the invoked command. | diff --git a/src/haiku.rs b/src/haiku.rs
index 28c85aa..4f7a599 100644
--- a/src/haiku.rs
+++ b/src/haiku.rs
@@ -9,12 +9,13 @@ pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
}
pub fn that<T: AsRef<OsStr>>(path: T) -> io::Result<()> {
- commands(path)[0].status_without_output().into_result()
+ let... | 6 | 29 | 35 |
245c95ede24adc6694d935993d6045d19a935035 | Sebastian Thiel | 2023-03-06T09:13:29 | feat: `commands()` function to obtain a list of launchers to open the given path.
This allows async applications to control the application launch in an async way,
for instance with `tokio`. | diff --git a/src/haiku.rs b/src/haiku.rs
index 1639c36..28c85aa 100644
--- a/src/haiku.rs
+++ b/src/haiku.rs
@@ -2,14 +2,14 @@ use std::{ffi::OsStr, io, process::Command};
use crate::{CommandExt, IntoResult};
-pub fn command<T: AsRef<OsStr>>(path: T) -> Command {
+pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<C... | 6 | 51 | 45 |
5644f17195244ca6d137f68f0f51a77d0be1fd99 | Sebastian Thiel | 2023-03-06T08:42:14 | remove dbg! statement | diff --git a/src/unix.rs b/src/unix.rs
index 7c61b00..cec2be9 100644
--- a/src/unix.rs
+++ b/src/unix.rs
@@ -24,7 +24,6 @@ pub fn command<T: AsRef<OsStr>>(path: T) -> Command {
if let Ok(_) = result {
let mut cmd = Command::new(command);
cmd.args(*args);
- dbg!(&cmd);
... | 1 | 0 | 1 |
55dc10dd1b3d04dbb0c7acb2b0a5efe7fc97dee6 | Sebastian Thiel | 2023-03-06T08:36:35 | fix: don't unnecessarily reject launchers on linux.
Previously it probably went through 5 launers assuming they don't work
before falling back to `xdg-open` which is usually present.
Now it will use the first launcher that it could invoke. | diff --git a/src/unix.rs b/src/unix.rs
index 044b63f..7c61b00 100644
--- a/src/unix.rs
+++ b/src/unix.rs
@@ -21,16 +21,15 @@ pub fn command<T: AsRef<OsStr>>(path: T) -> Command {
for (command, args) in &open_handlers {
let result = Command::new(command).status_without_output();
- if let Ok(status... | 1 | 6 | 7 |
8aa9bce4adbb66aefff4992b3ee7ee1d02774339 | Matouš Dzivjak | 2023-02-05T19:02:05 | try commands without args | diff --git a/src/unix.rs b/src/unix.rs
index 14bbca7..044b63f 100644
--- a/src/unix.rs
+++ b/src/unix.rs
@@ -11,17 +11,15 @@ use crate::{CommandExt, IntoResult};
pub fn command<T: AsRef<OsStr>>(path: T) -> Command {
let path = path.as_ref();
let open_handlers = [
- ("xdg-open", &["--version"], &[path]... | 2 | 10 | 10 |
fdd2ef013fe7dee1767694e229f4653f16d4ab8a | Matouš Dzivjak | 2023-02-05T18:15:38 | feat: add command function to return std::Command
Adds new `command` function that returns the underlying `std::Command`
that would be called to open given path.
Related: https://github.com/Byron/open-rs/pull/63
Related: https://github.com/helix-editor/helix/pull/5820 | diff --git a/src/haiku.rs b/src/haiku.rs
index 38bbf33..1639c36 100644
--- a/src/haiku.rs
+++ b/src/haiku.rs
@@ -2,11 +2,14 @@ use std::{ffi::OsStr, io, process::Command};
use crate::{CommandExt, IntoResult};
+pub fn command<T: AsRef<OsStr>>(path: T) -> Command {
+ let mut cmd = Command::new("/bin/open");
+ ... | 6 | 73 | 48 |
7ab725a2c6776a8f45305f71aec53650b45d9df7 | Sebastian Thiel | 2023-02-05T16:19:54 | refactor
- fix build
- don't quote path anymore as it's seemingly not required.
After all, we are passing the argument directly. | diff --git a/src/windows.rs b/src/windows.rs
index 7bd5bcb..b2b8658 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -1,36 +1,9 @@
-use std::{
- ffi::{OsStr, OsString},
- io,
- os::windows::ffi::OsStrExt,
- ptr,
-};
+use std::{ffi::OsStr, io};
-use std::os::raw::c_int;
-
-use crate::IntoResult;
-
-fn c... | 1 | 4 | 32 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.