1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
use std::borrow::{Borrow, Cow};
use std::collections::TryReserveError;
use std::hash::{Hash, Hasher};
use std::iter::{Extend, FromIterator};
use std::marker::PhantomData;
use std::ops::Deref;
use std::str::FromStr;
use std::string::FromUtf8Error;
use std::{cmp, fmt};
use crate::{Encoding, PathBuf, Utf8Encoding, Utf8Iter, Utf8Path};
/// An owned, mutable path that mirrors [`std::path::PathBuf`], but operatings using a
/// [`Utf8Encoding`] to determine how to parse the underlying str.
///
/// This type provides methods like [`push`] and [`set_extension`] that mutate
/// the path in place. It also implements [`Deref`] to [`Utf8Path`], meaning that
/// all methods on [`Utf8Path`] slices are available on `Utf8PathBuf` values as well.
///
/// [`push`]: Utf8PathBuf::push
/// [`set_extension`]: Utf8PathBuf::set_extension
///
/// # Examples
///
/// You can use [`push`] to build up a `Utf8PathBuf` from
/// components:
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8WindowsEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let mut path = Utf8PathBuf::<Utf8WindowsEncoding>::new();
///
/// path.push(r"C:\");
/// path.push("windows");
/// path.push("system32");
///
/// path.set_extension("dll");
/// ```
///
/// However, [`push`] is best used for dynamic situations. This is a better way
/// to do this when you know all of the components ahead of time:
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8WindowsEncoding};
///
/// let path: Utf8PathBuf<Utf8WindowsEncoding> = [
/// r"C:\",
/// "windows",
/// "system32.dll",
/// ].iter().collect();
/// ```
///
/// We can still do better than this! Since these are all strings, we can use
/// `From::from`:
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8WindowsEncoding};
///
/// let path = Utf8PathBuf::<Utf8WindowsEncoding>::from(r"C:\windows\system32.dll");
/// ```
///
/// Which method works best depends on what kind of situation you're in.
pub struct Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
/// Encoding associated with path buf
pub(crate) _encoding: PhantomData<T>,
/// Path as an unparsed string
pub(crate) inner: String,
}
impl<T> Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
/// Allocates an empty `Utf8PathBuf`.
///
/// # Examples
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8UnixEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let path = Utf8PathBuf::<Utf8UnixEncoding>::new();
/// ```
pub fn new() -> Self {
Utf8PathBuf {
_encoding: PhantomData,
inner: String::new(),
}
}
/// Creates a new `PathBuf` with a given capacity used to create the
/// internal [`String`]. See [`with_capacity`] defined on [`String`].
///
/// # Examples
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8UnixEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let mut path = Utf8PathBuf::<Utf8UnixEncoding>::with_capacity(10);
/// let capacity = path.capacity();
///
/// // This push is done without reallocating
/// path.push(r"C:\");
///
/// assert_eq!(capacity, path.capacity());
/// ```
///
/// [`with_capacity`]: String::with_capacity
#[inline]
pub fn with_capacity(capacity: usize) -> Self {
Utf8PathBuf {
_encoding: PhantomData,
inner: String::with_capacity(capacity),
}
}
/// Coerces to a [`Utf8Path`] slice.
///
/// # Examples
///
/// ```
/// use typed_path::{Utf8Path, Utf8PathBuf, Utf8UnixEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let p = Utf8PathBuf::<Utf8UnixEncoding>::from("/test");
/// assert_eq!(Utf8Path::new("/test"), p.as_path());
/// ```
#[inline]
pub fn as_path(&self) -> &Utf8Path<T> {
self
}
/// Extends `self` with `path`.
///
/// If `path` is absolute, it replaces the current path.
///
/// With [`Utf8WindowsPathBuf`]:
///
/// * if `path` has a root but no prefix (e.g., `\windows`), it
/// replaces everything except for the prefix (if any) of `self`.
/// * if `path` has a prefix but no root, it replaces `self`.
/// * if `self` has a verbatim prefix (e.g. `\\?\C:\windows`)
/// and `path` is not empty, the new path is normalized: all references
/// to `.` and `..` are removed.
///
/// [`Utf8WindowsPathBuf`]: crate::Utf8WindowsPathBuf
///
/// # Examples
///
/// Pushing a relative path extends the existing path:
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8UnixEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let mut path = Utf8PathBuf::<Utf8UnixEncoding>::from("/tmp");
/// path.push("file.bk");
/// assert_eq!(path, Utf8PathBuf::from("/tmp/file.bk"));
/// ```
///
/// Pushing an absolute path replaces the existing path:
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8UnixEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let mut path = Utf8PathBuf::<Utf8UnixEncoding>::from("/tmp");
/// path.push("/etc");
/// assert_eq!(path, Utf8PathBuf::from("/etc"));
/// ```
pub fn push<P: AsRef<Utf8Path<T>>>(&mut self, path: P) {
T::push(&mut self.inner, path.as_ref().as_str());
}
/// Truncates `self` to [`self.parent`].
///
/// Returns `false` and does nothing if [`self.parent`] is [`None`].
/// Otherwise, returns `true`.
///
/// [`self.parent`]: Utf8Path::parent
///
/// # Examples
///
/// ```
/// use typed_path::{Utf8Path, Utf8PathBuf, Utf8UnixEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let mut p = Utf8PathBuf::<Utf8UnixEncoding>::from("/spirited/away.rs");
///
/// p.pop();
/// assert_eq!(Utf8Path::new("/spirited"), p);
/// p.pop();
/// assert_eq!(Utf8Path::new("/"), p);
/// ```
pub fn pop(&mut self) -> bool {
match self.parent().map(|p| p.as_str().len()) {
Some(len) => {
self.inner.truncate(len);
true
}
None => false,
}
}
/// Updates [`self.file_name`] to `file_name`.
///
/// If [`self.file_name`] was [`None`], this is equivalent to pushing
/// `file_name`.
///
/// Otherwise it is equivalent to calling [`pop`] and then pushing
/// `file_name`. The new path will be a sibling of the original path.
/// (That is, it will have the same parent.)
///
/// [`self.file_name`]: Utf8Path::file_name
/// [`pop`]: Utf8PathBuf::pop
///
/// # Examples
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8UnixEncoding};
///
/// // NOTE: A pathbuf cannot be created on its own without a defined encoding
/// let mut buf = Utf8PathBuf::<Utf8UnixEncoding>::from("/");
/// assert!(buf.file_name() == None);
/// buf.set_file_name("bar");
/// assert!(buf == Utf8PathBuf::from("/bar"));
/// assert!(buf.file_name().is_some());
/// buf.set_file_name("baz.txt");
/// assert!(buf == Utf8PathBuf::from("/baz.txt"));
/// ```
pub fn set_file_name<S: AsRef<str>>(&mut self, file_name: S) {
self._set_file_name(file_name.as_ref())
}
fn _set_file_name(&mut self, file_name: &str) {
if self.file_name().is_some() {
let popped = self.pop();
debug_assert!(popped);
}
self.push(file_name);
}
/// Updates [`self.extension`] to `extension`.
///
/// Returns `false` and does nothing if [`self.file_name`] is [`None`],
/// returns `true` and updates the extension otherwise.
///
/// If [`self.extension`] is [`None`], the extension is added; otherwise
/// it is replaced.
///
/// [`self.file_name`]: Utf8Path::file_name
/// [`self.extension`]: Utf8Path::extension
///
/// # Examples
///
/// ```
/// use typed_path::{Utf8Path, Utf8PathBuf, Utf8UnixEncoding};
///
/// let mut p = Utf8PathBuf::<Utf8UnixEncoding>::from("/feel/the");
///
/// p.set_extension("force");
/// assert_eq!(Utf8Path::new("/feel/the.force"), p.as_path());
///
/// p.set_extension("dark_side");
/// assert_eq!(Utf8Path::new("/feel/the.dark_side"), p.as_path());
/// ```
pub fn set_extension<S: AsRef<str>>(&mut self, extension: S) -> bool {
self._set_extension(extension.as_ref())
}
fn _set_extension(&mut self, extension: &str) -> bool {
if self.file_stem().is_none() {
return false;
}
let old_ext_len = self.extension().map(|ext| ext.len()).unwrap_or(0);
// Truncate to remove the extension
if old_ext_len > 0 {
self.inner.truncate(self.inner.len() - old_ext_len);
// If we end with a '.' now from the previous extension, remove that too
if self.inner.ends_with('.') {
self.inner.pop();
}
}
// Add the new extension if it exists
if !extension.is_empty() {
// Add a '.' at the end prior to adding the extension
if !self.inner.ends_with('.') {
self.inner.push('.');
}
self.inner.push_str(extension);
}
true
}
/// Consumes the `PathBuf`, yielding its internal [`String`] storage.
///
/// # Examples
///
/// ```
/// use typed_path::{Utf8PathBuf, Utf8UnixEncoding};
///
/// let p = Utf8PathBuf::<Utf8UnixEncoding>::from("/the/head");
/// let s = p.into_string();
/// ```
#[inline]
pub fn into_string(self) -> String {
self.inner
}
/// Converts this [`Utf8PathBuf`] into a [boxed](Box) [`Utf8Path`].
#[inline]
pub fn into_boxed_path(self) -> Box<Utf8Path<T>> {
let rw = Box::into_raw(self.inner.into_boxed_str()) as *mut Utf8Path<T>;
unsafe { Box::from_raw(rw) }
}
/// Invokes [`capacity`] on the underlying instance of [`String`].
///
/// [`capacity`]: String::capacity
#[inline]
pub fn capacity(&self) -> usize {
self.inner.capacity()
}
/// Invokes [`clear`] on the underlying instance of [`String`].
///
/// [`clear`]: String::clear
#[inline]
pub fn clear(&mut self) {
self.inner.clear()
}
/// Invokes [`reserve`] on the underlying instance of [`String`].
///
/// [`reserve`]: String::reserve
#[inline]
pub fn reserve(&mut self, additional: usize) {
self.inner.reserve(additional)
}
/// Invokes [`try_reserve`] on the underlying instance of [`String`].
///
/// [`try_reserve`]: String::try_reserve
#[inline]
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
self.inner.try_reserve(additional)
}
/// Invokes [`reserve_exact`] on the underlying instance of [`String`].
///
/// [`reserve_exact`]: String::reserve_exact
#[inline]
pub fn reserve_exact(&mut self, additional: usize) {
self.inner.reserve_exact(additional)
}
/// Invokes [`try_reserve_exact`] on the underlying instance of [`String`].
///
/// [`try_reserve_exact`]: String::try_reserve_exact
#[inline]
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
self.inner.try_reserve_exact(additional)
}
/// Invokes [`shrink_to_fit`] on the underlying instance of [`String`].
///
/// [`shrink_to_fit`]: String::shrink_to_fit
#[inline]
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit()
}
/// Invokes [`shrink_to`] on the underlying instance of [`String`].
///
/// [`shrink_to`]: String::shrink_to
#[inline]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.inner.shrink_to(min_capacity)
}
/// Consumes [`PathBuf`] and returns a new [`Utf8PathBuf`] by checking that the path contains
/// valid UTF-8.
///
/// # Errors
///
/// Returns `Err` if the path is not UTF-8 with a description as to why the
/// provided component is not UTF-8.
///
/// # Examples
///
/// ```
/// use typed_path::{PathBuf, Utf8PathBuf, UnixEncoding, Utf8UnixEncoding};
///
/// let path_buf = PathBuf::<UnixEncoding>::from(&[0xf0, 0x9f, 0x92, 0x96]);
/// let utf8_path_buf = Utf8PathBuf::<Utf8UnixEncoding>::from_bytes_path_buf(path_buf).unwrap();
/// assert_eq!(utf8_path_buf.as_str(), "💖");
/// ```
pub fn from_bytes_path_buf<U>(path_buf: PathBuf<U>) -> Result<Self, FromUtf8Error>
where
U: for<'enc> Encoding<'enc>,
{
Ok(Self {
_encoding: PhantomData,
inner: String::from_utf8(path_buf.inner)?,
})
}
/// Consumes [`PathBuf`] and returns a new [`Utf8PathBuf`] by checking that the path contains
/// valid UTF-8.
///
/// # Errors
///
/// Returns `Err` if the path is not UTF-8 with a description as to why the
/// provided component is not UTF-8.
///
/// # Safety
///
/// The path passed in must be valid UTF-8.
///
/// # Examples
///
/// ```
/// use typed_path::{PathBuf, Utf8PathBuf, UnixEncoding, Utf8UnixEncoding};
///
/// let path_buf = PathBuf::<UnixEncoding>::from(&[0xf0, 0x9f, 0x92, 0x96]);
/// let utf8_path_buf = unsafe {
/// Utf8PathBuf::<Utf8UnixEncoding>::from_bytes_path_buf_unchecked(path_buf)
/// };
/// assert_eq!(utf8_path_buf.as_str(), "💖");
/// ```
pub unsafe fn from_bytes_path_buf_unchecked<U>(path_buf: PathBuf<U>) -> Self
where
U: for<'enc> Encoding<'enc>,
{
Self {
_encoding: PhantomData,
inner: String::from_utf8_unchecked(path_buf.inner),
}
}
/// Consumes [`Utf8PathBuf`] and returns a new [`PathBuf`]
///
/// # Examples
///
/// ```
/// use typed_path::{PathBuf, Utf8PathBuf, UnixEncoding, Utf8UnixEncoding};
///
/// let utf8_path_buf = Utf8PathBuf::<Utf8UnixEncoding>::from("💖");
/// let path_buf = utf8_path_buf.into_bytes_path_buf::<UnixEncoding>();
/// assert_eq!(path_buf.as_bytes(), &[0xf0, 0x9f, 0x92, 0x96]);
/// ```
pub fn into_bytes_path_buf<U>(self) -> PathBuf<U>
where
U: for<'enc> Encoding<'enc>,
{
PathBuf {
_encoding: PhantomData,
inner: self.inner.into_bytes(),
}
}
}
impl<T> Clone for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn clone(&self) -> Self {
Self {
_encoding: self._encoding,
inner: self.inner.clone(),
}
}
}
impl<T> fmt::Debug for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Utf8PathBuf")
.field("_encoding", &T::label())
.field("inner", &self.inner)
.finish()
}
}
impl<T> AsRef<[u8]> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn as_ref(&self) -> &[u8] {
self.as_str().as_bytes()
}
}
impl<T> AsRef<str> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<T> AsRef<Utf8Path<T>> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn as_ref(&self) -> &Utf8Path<T> {
self
}
}
impl<T> Borrow<Utf8Path<T>> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn borrow(&self) -> &Utf8Path<T> {
self.deref()
}
}
impl<T> Default for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn default() -> Utf8PathBuf<T> {
Utf8PathBuf::new()
}
}
impl<T> fmt::Display for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.inner, f)
}
}
impl<T> Deref for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
type Target = Utf8Path<T>;
#[inline]
fn deref(&self) -> &Utf8Path<T> {
Utf8Path::new(&self.inner)
}
}
impl<T> Eq for Utf8PathBuf<T> where T: for<'enc> Utf8Encoding<'enc> {}
impl<T> PartialEq for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
fn eq(&self, other: &Self) -> bool {
self.components() == other.components()
}
}
impl<T, P> Extend<P> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
P: AsRef<Utf8Path<T>>,
{
fn extend<I: IntoIterator<Item = P>>(&mut self, iter: I) {
iter.into_iter().for_each(move |p| self.push(p.as_ref()));
}
}
impl<T> From<Box<Utf8Path<T>>> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
fn from(boxed: Box<Utf8Path<T>>) -> Self {
boxed.into_path_buf()
}
}
impl<T, V> From<&V> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
V: ?Sized + AsRef<str>,
{
/// Converts a borrowed [`str`] to a [`Utf8PathBuf`].
///
/// Allocates a [`Utf8PathBuf`] and copies the data into it.
#[inline]
fn from(s: &V) -> Self {
Utf8PathBuf::from(s.as_ref().to_string())
}
}
impl<T> From<String> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
/// Converts a [`String`] into a [`Utf8PathBuf`]
///
/// This conversion does not allocate or copy memory.
#[inline]
fn from(inner: String) -> Self {
Utf8PathBuf {
_encoding: PhantomData,
inner,
}
}
}
impl<T> From<Utf8PathBuf<T>> for String
where
T: for<'enc> Utf8Encoding<'enc>,
{
/// Converts a [`Utf8PathBuf`] into a [`String`]
///
/// This conversion does not allocate or copy memory.
#[inline]
fn from(path_buf: Utf8PathBuf<T>) -> Self {
path_buf.inner
}
}
impl<T> FromStr for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
type Err = core::convert::Infallible;
#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Utf8PathBuf::from(s))
}
}
impl<'a, T> From<Cow<'a, Utf8Path<T>>> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
/// Converts a clone-on-write pointer to an owned path.
///
/// Converting from a `Cow::Owned` does not clone or allocate.
#[inline]
fn from(p: Cow<'a, Utf8Path<T>>) -> Self {
p.into_owned()
}
}
impl<T, P> FromIterator<P> for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
P: AsRef<Utf8Path<T>>,
{
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> Self {
let mut buf = Utf8PathBuf::new();
buf.extend(iter);
buf
}
}
impl<T> Hash for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
fn hash<H: Hasher>(&self, h: &mut H) {
self.as_path().hash(h)
}
}
impl<'a, T> IntoIterator for &'a Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
type IntoIter = Utf8Iter<'a, T>;
type Item = &'a str;
#[inline]
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
impl<T> cmp::PartialOrd for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
self.components().partial_cmp(other.components())
}
}
impl<T> cmp::Ord for Utf8PathBuf<T>
where
T: for<'enc> Utf8Encoding<'enc>,
{
#[inline]
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.components().cmp(other.components())
}
}