Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/std_misc/path.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Path

The `Path` struct represents file paths in the underlying filesystem. There are
two flavors of `Path`: `posix::Path`, for UNIX-like systems, and
`windows::Path`, for Windows. The prelude exports the appropriate
platform-specific `Path` variant.
The `Path` type represents file paths in the underlying filesystem. Across all
platforms there is a single `std::path::Path` that abstracts over
platform-specific path semantics and separators. Bring it into scope with
`use std::path::Path;` when needed.

A `Path` can be created from an `OsStr`, and provides several methods to get
information from the file/directory the path points to.
Expand Down Expand Up @@ -47,8 +47,7 @@ fn main() {
}
```

Be sure to check at other `Path` methods (`posix::Path` or `windows::Path`) and
the `Metadata` struct.
Be sure to check other `Path` methods and the `Metadata` struct.

### See also:

Expand Down
19 changes: 18 additions & 1 deletion theme/js/language-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,28 @@
language == "en" ? `${mdbookPathToRoot}` : `${mdbookPathToRoot}../`;
// The page path (mdbook only gives us access to the path to the Markdown file).
let path = mdbookPath.replace(/\.md$/, ".html");
for (let lang of langList.querySelectorAll("a")) {
const langAnchors = Array.from(langList.querySelectorAll("a"));
for (let lang of langAnchors) {
if (lang.id == "en") {
lang.href = `${full_path_to_root}${path}`;
} else {
lang.href = `${full_path_to_root}${lang.id}/${path}`;
}
}

// Hide languages whose target page is not available (e.g., not deployed).
// This prevents users from hitting 404s on sites that only ship some locales.
for (let lang of langAnchors) {
const url = lang.href;
// Attempt a lightweight HEAD request; fall back to hiding on failure.
fetch(url, { method: "HEAD" }).then((resp) => {
if (!resp.ok) {
const li = lang.parentNode && lang.parentNode.parentNode;
if (li) li.style.display = "none";
}
}).catch(() => {
const li = lang.parentNode && lang.parentNode.parentNode;
if (li) li.style.display = "none";
});
}
})();