/* When static files are updated, their suffixes need to be updated. 1. In the top directory run: ./x.py doc --stage 1 library/core 2. Find the directory containing files named with updated suffixes: find build -path '*'/stage1-std/'*'/static.files 3. Copy the filenames with updated suffixes from the directory. */ :root { --nav-sub-mobile-padding: 8px; --search-typename-width: 6.75rem; /* DEFAULT_SIDEBAR_WIDTH see main.js for information on these values and on the RUSTDOC_MOBILE_BREAKPOINT */ --desktop-sidebar-width: 200px; --src-sidebar-width: 300px; --desktop-sidebar-z-index: 100; } /* See FiraSans-LICENSE.txt for the Fira Sans license. */ @font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; src: local('Fira Sans'), url("FiraSans-Regular-018c141bf0843ffd.woff2") format("woff2"); font-display: swap; } @font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; src: local('Fira Sans Medium'), url("FiraSans-Medium-8f9a781e4970d388.woff2") format("woff2"); font-display: swap; } /* See SourceSerif4-LICENSE.md for the Source Serif 4 license. */ @font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 400; src: local('Source Serif 4'), url("SourceSerif4-Regular-46f98efaafac5295.ttf.woff2") format("woff2"); font-display: swap; } @font-face { font-family: 'Source Serif 4'; font-style: italic; font-weight: 400; src: local('Source Serif 4 Italic'), url("SourceSerif4-It-acdfaf1a8af734b1.ttf.woff2") format("woff2"); font-display: swap; } @font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 700; src: local('Source Serif 4 Bold'), url("SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2") format("woff2"); font-display: swap; } /* See SourceCodePro-LICENSE.txt for the Source Code Pro license. */ @font-face { font-family: 'Source Code Pro'; font-style: normal; font-weight: 400; /* Avoid using locally installed font because bad versions are in circulation: * see https://github.com/rust-lang/rust/issues/24355 */ src: url("SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2") format("woff2"); font-display: swap; } @font-face { font-family: 'Source Code Pro'; font-style: italic; font-weight: 400; src: url("SourceCodePro-It-1cc31594bf4f1f79.ttf.woff2") format("woff2"); font-display: swap; } @font-face { font-family: 'Source Code Pro'; font-style: normal; font-weight: 600; src: url("SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2") format("woff2"); font-display: swap; } /* Avoid using legacy CJK serif fonts in Windows like Batang. */ @font-face { font-family: 'NanumBarunGothic'; src: url("NanumBarunGothic-0f09457c7a19b7c6.ttf.woff2") format("woff2"); font-display: swap; unicode-range: U+AC00-D7AF, U+1100-11FF, U+3130-318F, U+A960-A97F, U+D7B0-D7FF; } * { box-sizing: border-box; } /* General structure and fonts */ body { /* Line spacing at least 1.5 per Web Content Accessibility Guidelines https://www.w3.org/WAI/WCAG21/Understanding/visual-presentation.html */ font: 1rem/1.5 "Source Serif 4", NanumBarunGothic, serif; margin: 0; position: relative; /* We use overflow-wrap: break-word for Safari, which doesn't recognize `anywhere`: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap */ overflow-wrap: break-word; /* Then override it with `anywhere`, which is required to make non-Safari browsers break more aggressively when we want them to. */ overflow-wrap: anywhere; font-feature-settings: "kern", "liga"; background-color: var(--main-background-color); color: var(--main-color); } h1 { font-size: 1.5rem; /* 24px */ } h2 { font-size: 1.375rem; /* 22px */ } h3 { font-size: 1.25rem; /* 20px */ } h1, h2, h3, h4, h5, h6 { font-weight: 500; } h1, h2, h3, h4 { margin: 25px 0 15px 0; padding-bottom: 6px; } .docblock h3, .docblock h4, h5, h6 { margin: 15px 0 5px 0; } .docblock > h2:first-child, .docblock > h3:first-child, .docblock > h4:first-child, .docblock > h5:first-child, .docblock > h6:first-child { margin-top: 0; } .main-heading h1 { margin: 0; padding: 0; flex-grow: 1; /* We use overflow-wrap: break-word for Safari, which doesn't recognize `anywhere`: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap */ overflow-wrap: break-word; /* Then override it with `anywhere`, which is required to make non-Safari browsers break more aggressively when we want them to. */ overflow-wrap: anywhere; } .main-heading { display: flex; flex-wrap: wrap; padding-bottom: 6px; margin-bottom: 15px; } /* The only headings that get underlines are: Markdown-generated headings within the top-doc Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc) Underlines elsewhere in the documentation break up visual flow and tend to invert section hierarchies. */ .content h2, .top-doc .docblock > h3, .top-doc .docblock > h4 { border-bottom: 1px solid var(--headings-border-bottom-color); } /* while line-height 1.5 is required for any "block of text", which WCAG defines as more than one sentence, it looks weird for very large main headers */ h1, h2 { line-height: 1.25; padding-top: 3px; padding-bottom: 9px; } h3.code-header { font-size: 1.125rem; /* 18px */ } h4.code-header { font-size: 1rem; } .code-header { font-weight: 600; margin: 0; padding: 0; white-space: pre-wrap; } #crate-search, h1, h2, h3, h4, h5, h6, .sidebar, .mobile-topbar, .search-input, .search-results .result-name, .item-name > a, .out-of-band, span.since, a.src, #help-button > a, summary.hideme, .scraped-example-list, /* This selector is for the items listed in the "all items" page. */ ul.all-items { font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif; } #toggle-all-docs, a.anchor, .section-header a, #src-sidebar a, .rust a, .sidebar h2 a, .sidebar h3 a, .mobile-topbar h2 a, h1 a, .search-results a, .stab, .result-name i { color: var(--main-color); } span.enum, a.enum, span.struct, a.struct, span.union, a.union, span.primitive, a.primitive, span.type, a.type, span.foreigntype, a.foreigntype { color: var(--type-link-color); } span.trait, a.trait, span.traitalias, a.traitalias { color: var(--trait-link-color); } span.associatedtype, a.associatedtype, span.constant, a.constant, span.static, a.static { color: var(--assoc-item-link-color); } span.fn, a.fn, span.method, a.method, span.tymethod, a.tymethod { color: var(--function-link-color); } span.attr, a.attr, span.derive, a.derive, span.macro, a.macro { color: var(--macro-link-color); } span.mod, a.mod { color: var(--mod-link-color); } span.keyword, a.keyword { color: var(--keyword-link-color); } a { color: var(--link-color); text-decoration: none; } ol, ul { padding-left: 24px; } ul ul, ol ul, ul ol, ol ol { margin-bottom: .625em; } p, .docblock > .warning { /* Paragraph spacing at least 1.5 times line spacing per Web Content Accessibility Guidelines. Line-height is 1.5rem, so line spacing is .5rem; .75em is 1.5 times that. https://www.w3.org/WAI/WCAG21/Understanding/visual-presentation.html */ margin: 0 0 .75em 0; } /* For the last child of a div, the margin will be taken care of by the margin-top of the next item. */ p:last-child, .docblock > .warning:last-child { margin: 0; } /* Fix some style changes due to normalize.css 8 */ button { /* Buttons on Safari have different default padding than other platforms. Make them the same. */ padding: 1px 6px; /* Opinionated tweak: use pointer cursor as clickability signifier. */ cursor: pointer; } /* end tweaks for normalize.css 8 */ button#toggle-all-docs { padding: 0; background: none; border: none; /* iOS button gradient: https://stackoverflow.com/q/5438567 */ -webkit-appearance: none; opacity: 1; } .rustdoc { display: flex; flex-direction: row; flex-wrap: nowrap; } main { position: relative; flex-grow: 1; padding: 10px 15px 40px 45px; min-width: 0; /* avoid growing beyond the size limit */ } .src main { padding: 15px; } .width-limiter { max-width: 960px; margin-right: auto; } details:not(.toggle) summary { margin-bottom: .6em; } code, pre, a.test-arrow, .code-header { font-family: "Source Code Pro", monospace; } .docblock code, .docblock-short code { border-radius: 3px; padding: 0 0.125em; } .docblock pre code, .docblock-short pre code { padding: 0; } pre { padding: 14px; line-height: 1.5; /* https://github.com/rust-lang/rust/issues/105906 */ } pre.item-decl { overflow-x: auto; } /* This rule allows to have scrolling on the X axis. */ .item-decl .type-contents-toggle { contain: initial; } .src .content pre { padding: 20px; } .rustdoc.src .example-wrap pre.src-line-numbers { padding: 20px 0 20px 4px; } img { max-width: 100%; } .sub-logo-container, .logo-container { /* zero text boxes so that computed line height = image height exactly */ line-height: 0; display: block; } .sub-logo-container { margin-right: 32px; } .sub-logo-container > img { height: 60px; width: 60px; object-fit: contain; } .rust-logo { filter: var(--rust-logo-filter); } .sidebar { font-size: 0.875rem; flex: 0 0 var(--desktop-sidebar-width); width: var(--desktop-sidebar-width); overflow-y: scroll; overscroll-behavior: contain; position: sticky; height: 100vh; top: 0; left: 0; z-index: var(--desktop-sidebar-z-index); } .rustdoc.src .sidebar { flex-basis: 50px; border-right: 1px solid; overflow-x: hidden; /* The sidebar is by default hidden */ overflow-y: hidden; } .hide-sidebar .sidebar, .hide-sidebar .sidebar-resizer { display: none; } .sidebar-resizer { touch-action: none; width: 9px; cursor: col-resize; z-index: calc(var(--desktop-sidebar-z-index) + 1); position: fixed; height: 100%; /* make sure there's a 1px gap between the scrollbar and resize handle */ left: calc(var(--desktop-sidebar-width) + 1px); } .rustdoc.src .sidebar-resizer { /* when closed, place resizer glow on top of the normal src sidebar border (no need to worry about sidebar) */ left: 49px; } .src-sidebar-expanded .rustdoc.src .sidebar-resizer { /* for src sidebar, gap is already provided by 1px border on sidebar itself, so place resizer to right of it */ left: var(--src-sidebar-width); } .sidebar-resizing { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; } .sidebar-resizing * { cursor: col-resize !important; } .sidebar-resizing .sidebar { position: fixed; } .sidebar-resizing > body { padding-left: var(--resizing-sidebar-width); } .sidebar-resizer:hover, .sidebar-resizer:active, .sidebar-resizer:focus, .sidebar-resizer.active { width: 10px; margin: 0; /* when active or hovered, place resizer glow on top of the sidebar (right next to, or even on top of, the scrollbar) */ left: var(--desktop-sidebar-width); border-left: solid 1px var(--sidebar-resizer-hover); } .src-sidebar-expanded .rustdoc.src .sidebar-resizer:hover, .src-sidebar-expanded .rustdoc.src .sidebar-resizer:active, .src-sidebar-expanded .rustdoc.src .sidebar-resizer:focus, .src-sidebar-expanded .rustdoc.src .sidebar-resizer.active { /* when active or hovered, place resizer glow on top of the normal src sidebar border */ left: calc(var(--src-sidebar-width) - 1px); } @media (pointer: coarse) { .sidebar-resizer { /* too easy to hit the resizer while trying to hit the [-] toggle */ display: none !important; } } .sidebar-resizer.active { /* make the resize tool bigger when actually resizing, to avoid :hover styles on other stuff while resizing */ padding: 0 140px; width: 2px; margin-left: -140px; border-left: none; } .sidebar-resizer.active:before { border-left: solid 2px var(--sidebar-resizer-active); display: block; height: 100%; content: ""; } .sidebar, .mobile-topbar, .sidebar-menu-toggle, #src-sidebar-toggle, #src-sidebar { background-color: var(--sidebar-background-color); } #src-sidebar-toggle > button:hover, #src-sidebar-toggle > button:focus { background-color: var(--sidebar-background-color-hover); } .src .sidebar > *:not(#src-sidebar-toggle) { visibility: hidden; } .src-sidebar-expanded .src .sidebar { overflow-y: auto; flex-basis: var(--src-sidebar-width); width: var(--src-sidebar-width); } .src-sidebar-expanded .src .sidebar > *:not(#src-sidebar-toggle) { visibility: visible; } #all-types { margin-top: 1em; } /* Improve the scrollbar display on firefox */ * { scrollbar-width: initial; scrollbar-color: var(--scrollbar-color); } .sidebar { scrollbar-width: thin; scrollbar-color: var(--scrollbar-color); } /* Improve the scrollbar display on webkit-based browsers */ ::-webkit-scrollbar { width: 12px; } .sidebar::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0; background-color: var(--scrollbar-track-background-color); } .sidebar::-webkit-scrollbar-track { background-color: var(--scrollbar-track-background-color); } ::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb { background-color: var(--scrollbar-thumb-background-color); } /* Everything else */ .hidden { display: none !important; } .logo-container > img { height: 48px; width: 48px; } ul.block, .block li { padding: 0; margin: 0; list-style: none; } .sidebar-elems a, .sidebar > h2 a { display: block; padding: 0.25rem; /* 4px */ margin-left: -0.25rem; margin-right: 0.25rem; } .sidebar h2 { overflow-wrap: anywhere; padding: 0; margin: 0.7rem 0; } .sidebar h3 { font-size: 1.125rem; /* 18px */ padding: 0; margin: 0; } .sidebar-elems, .sidebar > .version, .sidebar > h2 { padding-left: 24px; } .sidebar a { color: var(--sidebar-link-color); } .sidebar .current, .sidebar .current a, .sidebar-crate a.logo-container:hover + h2 a, .sidebar a:hover:not(.logo-container) { background-color: var(--sidebar-current-link-background-color); } .sidebar-elems .block { margin-bottom: 2em; } .sidebar-elems .block li a { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } .sidebar-crate { display: flex; align-items: center; justify-content: center; /* there's a 10px padding at the top of
, and a 4px margin at the top of the search form. To line them up, add them. */ margin: 14px 32px 1rem; row-gap: 10px; column-gap: 32px; flex-wrap: wrap; } .sidebar-crate h2 { flex-grow: 1; /* This setup with the margins and row-gap is designed to make flex-wrap work the way we want. If they're in the side-by-side lockup, there should be a 16px margin to the left of the logo (visually the same as the 24px one on everything else, which are not giant circles) and 8px between it and the crate's name and version. When they're line wrapped, the logo needs to have the same margin on both sides of itself (to center properly) and the crate name and version need 24px on their left margin. */ margin: 0 -8px; /* To align this with the search bar, it should not be centered, even when the logo is. */ align-self: start; } .sidebar-crate .logo-container { /* The logo is expected to have 8px "slop" along its edges, so we can optically center it. */ margin: 0 -16px 0 -16px; text-align: center; } .sidebar-crate h2 a { display: block; margin: 0 calc(-24px + 0.25rem) 0 -0.5rem; /* Align the sidebar crate link with the search bar, which have different font sizes. | | font-size | line-height | total line-height | padding-y | total | |:-------|----------:|------------:|------------------:|----------:|-------------:| | crate | 1.375rem | 1.25 | 1.72rem | x | 2x+1.72rem | | search | 1rem | 1.15 | 1.15rem | 8px | 1.15rem+16px | 2x + 1.72rem = 1.15rem + 16px 2x = 1.15rem + 16px - 1.72rem 2x = 16px - 0.57rem x = ( 16px - 0.57rem ) / 2 */ padding: calc( ( 16px - 0.57rem ) / 2 ) 0.25rem; padding-left: 0.5rem; } .sidebar-crate h2 .version { display: block; font-weight: normal; font-size: 1rem; overflow-wrap: break-word; /* opposite of the link padding, cut in half again */ margin-top: calc( ( -16px + 0.57rem ) / 2 ); } .sidebar-crate + .version { margin-top: -1rem; margin-bottom: 1rem; } .mobile-topbar { display: none; } .rustdoc .example-wrap { display: flex; position: relative; margin-bottom: 10px; } /* For the last child of a div, the margin will be taken care of by the margin-top of the next item. */ .rustdoc .example-wrap:last-child { margin-bottom: 0px; } .rustdoc .example-wrap pre { margin: 0; flex-grow: 1; } .rustdoc:not(.src) .example-wrap pre { overflow: auto hidden; } .rustdoc .example-wrap pre.example-line-numbers, .rustdoc .example-wrap pre.src-line-numbers { flex-grow: 0; min-width: fit-content; /* prevent collapsing into nothing in truncated scraped examples */ overflow: initial; text-align: right; -webkit-user-select: none; user-select: none; padding: 14px 8px; color: var(--src-line-numbers-span-color); } .rustdoc .example-wrap pre.src-line-numbers { padding: 14px 0; } .src-line-numbers a, .src-line-numbers span { color: var(--src-line-numbers-span-color); padding: 0 8px; } .src-line-numbers :target { background-color: transparent; border-right: none; padding: 0 8px; } .src-line-numbers .line-highlighted { background-color: var(--src-line-number-highlighted-background-color); } .search-loading { text-align: center; } .docblock-short { overflow-wrap: break-word; overflow-wrap: anywhere; } /* Wrap non-pre code blocks (`text`) but not (```text```). */ .docblock :not(pre) > code, .docblock-short code { white-space: pre-wrap; } .top-doc .docblock h2 { font-size: 1.375rem; } .top-doc .docblock h3 { font-size: 1.25rem; } .top-doc .docblock h4, .top-doc .docblock h5 { font-size: 1.125rem; } .top-doc .docblock h6 { font-size: 1rem; } .docblock h5 { font-size: 1rem; } .docblock h6 { font-size: 0.875rem; } .docblock { margin-left: 24px; position: relative; } .docblock > :not(.more-examples-toggle):not(.example-wrap) { max-width: 100%; overflow-x: auto; } .out-of-band { flex-grow: 0; font-size: 1.125rem; } .docblock code, .docblock-short code, pre, .rustdoc.src .example-wrap { background-color: var(--code-block-background-color); } #main-content { position: relative; } .docblock table { margin: .5em 0; border-collapse: collapse; } .docblock table td, .docblock table th { padding: .5em; border: 1px solid var(--border-color); } .docblock table tbody tr:nth-child(2n) { background: var(--table-alt-row-background-color); } /* "where ..." clauses with block display are also smaller */ div.where { white-space: pre-wrap; font-size: 0.875rem; } .item-info { display: block; margin-left: 24px; } .item-info code { font-size: 0.875rem; } #main-content > .item-info { margin-left: 0; } nav.sub { flex-grow: 1; flex-flow: row nowrap; margin: 4px 0 25px 0; display: flex; align-items: center; } .search-form { position: relative; display: flex; height: 34px; flex-grow: 1; } .src nav.sub { margin: 0 0 15px 0; } .section-header { /* fields use tags, but should get their own lines */ display: block; position: relative; } .section-header:hover > .anchor, .impl:hover > .anchor, .trait-impl:hover > .anchor, .variant:hover > .anchor { display: initial; } .anchor { display: none; position: absolute; left: -0.5em; background: none !important; } .anchor.field { left: -5px; } .section-header > .anchor { left: -15px; padding-right: 8px; } h2.section-header > .anchor { padding-right: 6px; } .main-heading a:hover, .example-wrap .rust a:hover, .all-items a:hover, .docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover, .docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover, .item-info a { text-decoration: underline; } .crate.block li.current a { font-weight: 500; } /* In most contexts we use `overflow-wrap: anywhere` to ensure that we can wrap as much as needed on mobile (see tests/rustdoc-gui/type-declaration-overflow.goml for an example of why this matters). The `anywhere` value means: "Soft wrap opportunities introduced by the word break are considered when calculating min-content intrinsic sizes." https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap#values For table layouts, that becomes a problem: the browser tries to make each column as narrow as possible, and `overflow-wrap: anywhere` means it can do so by breaking words - even if some other column could be shrunk without breaking words! This shows up, for instance, in the `Structs` / `Modules` / `Functions` (etcetera) sections of a module page, and when a docblock contains a table. So, for table layouts, override the default with break-word, which does _not_ affect min-content intrinsic sizes. */ table, .item-table { overflow-wrap: break-word; } .item-table { display: table; padding: 0; margin: 0; } .item-table > li { display: table-row; } .item-table > li > div { display: table-cell; } .item-table > li > .item-name { padding-right: 1.25rem; } .search-results-title { margin-top: 0; white-space: nowrap; /* flex layout allows shrinking the -element "#crate-search") to be shrunk */ min-width: 5em; } #crate-search { min-width: 115px; padding: 0 23px 0 4px; /* prevents the