Skip to content

Commit d72ec2e

Browse files
committed
---
yaml --- r: 136315 b: refs/heads/dist-snap c: ccae356 h: refs/heads/master i: 136313: 53755e1 136311: 32d7ece v: v3
1 parent e7d5022 commit d72ec2e

File tree

112 files changed

+3094
-5390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+3094
-5390
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 189b7332968972f34cdbbbd9b62d97ababf53059
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: c3943b3c89834db8cbeb7edc0a1e4b0002f11aa2
9+
refs/heads/dist-snap: ccae356aced284a964910006af22dc005ea073a2
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ documentation.
66
## Quick Start
77

88
1. Download a [binary installer][installer] for your platform.
9-
2. Read the [tutorial].
9+
2. Read the [guide].
1010
3. Enjoy!
1111

1212
> ***Note:*** Windows users can read the detailed
1313
> [getting started][wiki-start] notes on the wiki.
1414
1515
[installer]: http://www.rust-lang.org/install.html
16-
[tutorial]: http://doc.rust-lang.org/tutorial.html
16+
[guide]: http://doc.rust-lang.org/guide.html
1717
[wiki-start]: https://github.com/rust-lang/rust/wiki/Note-getting-started-developing-Rust
1818
[win-wiki]: https://github.com/rust-lang/rust/wiki/Using-Rust-on-Windows
1919

@@ -54,7 +54,7 @@ documentation.
5454
When complete, `make install` will place several programs into
5555
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
5656
API-documentation tool.
57-
3. Read the [tutorial].
57+
3. Read the [guide].
5858
4. Enjoy!
5959

6060
### Building on Windows
@@ -76,7 +76,7 @@ To easily build on windows we can use [MSYS2](http://sourceforge.net/projects/ms
7676

7777
[repo]: https://github.com/rust-lang/rust
7878
[tarball]: https://static.rust-lang.org/dist/rust-nightly.tar.gz
79-
[tutorial]: http://doc.rust-lang.org/tutorial.html
79+
[guide]: http://doc.rust-lang.org/guide.html
8080

8181
## Notes
8282

@@ -101,6 +101,18 @@ There is a lot more documentation in the [wiki].
101101

102102
[wiki]: https://github.com/rust-lang/rust/wiki
103103

104+
## Getting help and getting involved
105+
106+
The Rust community congregates in a few places:
107+
108+
* [StackOverflow] - Get help here.
109+
* [/r/rust] - General discussion.
110+
* [discuss.rust-lang.org] - For development of the Rust language itself.
111+
112+
[StackOverflow]: http://stackoverflow.com/questions/tagged/rust
113+
[/r/rust]: http://reddit.com/r/rust
114+
[discuss.rust-lang.org]: http://discuss.rust-lang.org/
115+
104116
## License
105117

106118
Rust is primarily distributed under the terms of both the MIT license

branches/dist-snap/mk/dist.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ distcheck-tar-src: dist-tar-src
112112

113113
ifdef CFG_ISCC
114114

115-
PKG_EXE = dist/$(PKG_NAME)-install.exe
115+
PKG_EXE = dist/$(PKG_NAME)-$(CFG_BUILD).exe
116116

117117
%.iss: $(S)src/etc/pkg/%.iss
118118
cp $< $@
@@ -123,7 +123,7 @@ PKG_EXE = dist/$(PKG_NAME)-install.exe
123123
$(PKG_EXE): rust.iss modpath.iss upgrade.iss LICENSE.txt rust-logo.ico \
124124
$(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
125125
dist-prepare-win
126-
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin
126+
$(CFG_PYTHON) $(S)src/etc/make-win-dist.py tmp/dist/win $(CFG_BUILD)
127127
@$(call E, ISCC: $@)
128128
$(Q)"$(CFG_ISCC)" $<
129129

branches/dist-snap/mk/docs.mk

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
# except according to those terms.
1010

1111
######################################################################
12-
# The various pieces of standalone documentation: guides, tutorial,
13-
# manual etc.
12+
# The various pieces of standalone documentation: guides, manual, etc
1413
#
1514
# The DOCS variable is their names (with no file extension).
1615
#
@@ -32,7 +31,7 @@ DOCS := index intro tutorial guide guide-ffi guide-macros guide-lifetimes \
3231
complement-lang-faq complement-design-faq complement-project-faq rust \
3332
rustdoc guide-unsafe guide-strings
3433

35-
PDF_DOCS := tutorial rust
34+
PDF_DOCS := guide rust
3635

3736
RUSTDOC_DEPS_rust := doc/full-toc.inc
3837
RUSTDOC_FLAGS_rust := --html-in-header=doc/full-toc.inc
@@ -76,21 +75,22 @@ endif
7675

7776
# Check for the various external utilities for the EPUB/PDF docs:
7877

79-
ifeq ($(CFG_PDFLATEX),)
80-
$(info cfg: no pdflatex found, deferring to xelatex)
78+
ifeq ($(CFG_LUALATEX),)
79+
$(info cfg: no lualatex found, deferring to xelatex)
8180
ifeq ($(CFG_XELATEX),)
82-
$(info cfg: no xelatex found, deferring to lualatex)
83-
ifeq ($(CFG_LUALATEX),)
84-
$(info cfg: no lualatex found, disabling LaTeX docs)
81+
$(info cfg: no xelatex found, deferring to pdflatex)
82+
ifeq ($(CFG_PDFLATEX),)
83+
$(info cfg: no pdflatex found, disabling LaTeX docs)
8584
NO_PDF_DOCS = 1
8685
else
87-
CFG_LATEX := $(CFG_LUALATEX)
86+
CFG_LATEX := $(CFG_PDFLATEX)
8887
endif
8988
else
9089
CFG_LATEX := $(CFG_XELATEX)
90+
XELATEX = 1
9191
endif
9292
else
93-
CFG_LATEX := $(CFG_PDFLATEX)
93+
CFG_LATEX := $(CFG_LUALATEX)
9494
endif
9595

9696

@@ -187,12 +187,25 @@ doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.tex | doc/
187187
ifneq ($(NO_PDF_DOCS),1)
188188
ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1)),1)
189189
DOC_TARGETS += doc/$(1).pdf
190+
ifneq ($(XELATEX),1)
190191
doc/$(1).pdf: doc/$(1).tex
191192
@$$(call E, latex compiler: $$@)
192193
$$(Q)$$(CFG_LATEX) \
193194
-interaction=batchmode \
194195
-output-directory=doc \
195196
$$<
197+
else
198+
# The version of xelatex on the snap bots seemingly ingores -output-directory
199+
# So we'll output to . and move to the doc directory manually.
200+
# This will leave some intermediate files in the build directory.
201+
doc/$(1).pdf: doc/$(1).tex
202+
@$$(call E, latex compiler: $$@)
203+
$$(Q)$$(CFG_LATEX) \
204+
-interaction=batchmode \
205+
-output-directory=. \
206+
$$<
207+
$$(Q)mv ./$(1).pdf $$@
208+
endif # XELATEX
196209
endif # SHOULD_BUILD_PDF_DOCS_$(1)
197210
endif # NO_PDF_DOCS
198211

@@ -212,7 +225,7 @@ $(foreach docname,$(DOCS),$(eval $(call DEF_DOC,$(docname))))
212225
#
213226
# As such, I've attempted to get it working as much as possible (and
214227
# switching from pandoc to rustdoc), but preserving the old behaviour
215-
# (e.g. only running on the tutorial)
228+
# (e.g. only running on the guide)
216229
.PHONY: l10n-mds
217230
l10n-mds: $(D)/po4a.conf \
218231
$(foreach lang,$(L10N_LANG),$(D)/po/$(lang)/*.md.po)
@@ -230,7 +243,7 @@ doc/l10n/$(1)/$(2).html: l10n-mds $$(HTML_DEPS) $$(RUSTDOC_DEPS_$(2))
230243
$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) doc/l10n/$(1)/$(2).md
231244
endef
232245

233-
$(foreach lang,$(L10N_LANGS),$(eval $(call DEF_L10N_DOC,$(lang),tutorial)))
246+
$(foreach lang,$(L10N_LANGS),$(eval $(call DEF_L10N_DOC,$(lang),guide)))
234247

235248

236249
######################################################################

branches/dist-snap/mk/reconfig.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
1515

1616
ifndef CFG_DISABLE_MANAGE_SUBMODULES
1717
# This is a pretty expensive operation but I don't see any way to avoid it
18-
NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
18+
# NB: This only looks for '+' status (wrong commit checked out), not '-' status
19+
# (nothing checked out at all). `./configure --{llvm,jemalloc,libuv}-root`
20+
# will explicitly deinitialize the corresponding submodules, and we don't
21+
# want to force constant rebuilds in that case.
22+
NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^+')
1923
else
2024
NEED_GIT_RECONFIG=0
2125
endif

branches/dist-snap/src/doc/guide-strings.md

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,33 @@ fn foo(s: String) {
9292
```
9393

9494
If you have good reason. It's not polite to hold on to ownership you don't
95-
need, and it can make your lifetimes more complex. Furthermore, you can pass
96-
either kind of string into `foo` by using `.as_slice()` on any `String` you
97-
need to pass in, so the `&str` version is more flexible.
95+
need, and it can make your lifetimes more complex.
96+
97+
## Generic functions
98+
99+
To write a function that's generic over types of strings, use [the `Str`
100+
trait](http://doc.rust-lang.org/std/str/trait.Str.html):
101+
102+
```{rust}
103+
fn some_string_length<T: Str>(x: T) -> uint {
104+
x.as_slice().len()
105+
}
106+
107+
fn main() {
108+
let s = "Hello, world";
109+
110+
println!("{}", some_string_length(s));
111+
112+
let s = "Hello, world".to_string();
113+
114+
println!("{}", some_string_length(s));
115+
}
116+
```
117+
118+
Both of these lines will print `12`.
119+
120+
The only method that the `Str` trait has is `as_slice()`, which gives you
121+
access to a `&str` value from the underlying string.
98122

99123
## Comparisons
100124

@@ -121,6 +145,65 @@ fn compare(string: String) {
121145
Converting a `String` to a `&str` is cheap, but converting the `&str` to a
122146
`String` involves an allocation.
123147

148+
## Indexing strings
149+
150+
You may be tempted to try to access a certain character of a `String`, like
151+
this:
152+
153+
```{rust,ignore}
154+
let s = "hello".to_string();
155+
156+
println!("{}", s[0]);
157+
```
158+
159+
This does not compile. This is on purpose. In the world of UTF-8, direct
160+
indexing is basically never what you want to do. The reason is that each
161+
character can be a variable number of bytes. This means that you have to iterate
162+
through the characters anyway, which is a O(n) operation.
163+
164+
To iterate over a string, use the `graphemes()` method on `&str`:
165+
166+
```{rust}
167+
let s = "αἰθήρ";
168+
169+
for l in s.graphemes(true) {
170+
println!("{}", l);
171+
}
172+
```
173+
174+
Note that `l` has the type `&str` here, since a single grapheme can consist of
175+
multiple codepoints, so a `char` wouldn't be appropriate.
176+
177+
This will print out each character in turn, as you'd expect: first "α", then
178+
"ἰ", etc. You can see that this is different than just the individual bytes.
179+
Here's a version that prints out each byte:
180+
181+
```{rust}
182+
let s = "αἰθήρ";
183+
184+
for l in s.bytes() {
185+
println!("{}", l);
186+
}
187+
```
188+
189+
This will print:
190+
191+
```{notrust,ignore}
192+
206
193+
177
194+
225
195+
188
196+
176
197+
206
198+
184
199+
206
200+
174
201+
207
202+
129
203+
```
204+
205+
Many more bytes than graphemes!
206+
124207
# Other Documentation
125208

126209
* [the `&str` API documentation](/std/str/index.html)

0 commit comments

Comments
 (0)