File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 9696 - [ ` literal ` macro matcher] ( rust-next/literal-macro-matcher.md )
9797 - [ ` ? ` operator in macros] ( rust-next/qustion-mark-operator-in-macros.md )
9898 - [ const fn] ( rust-next/const-fn.md )
99- - [ Pinning] ( rust-next/pin.md )
99+ - [ Pinning] ( rust-next/pin.md )
100+ - [ Alternative Cargo Registries] ( rust-next/alternative-cargo-registries.md )
101+ - [ TryFrom and TryInto] ( rust-next/tryfrom-and-tryinto.md )
Original file line number Diff line number Diff line change 1+ # Alternative Cargo registries
2+
3+ Initially added: ![ Minimum Rust version: 1.34] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.34-brightgreen.svg )
4+
5+ For various reasons, you may not want to publish code to crates.io, but you
6+ may want to share it with others. For example, maybe your company writes Rust
7+ code that's not open source, but you'd still like to use these internal
8+ packages.
9+
10+ Cargo supports alternative registries by settings in ` .cargo/config ` :
11+
12+ ``` toml
13+ [registries ]
14+ my-registry = { index = " https://my-intranet:7878/git/index" }
15+ ```
16+
17+ When you want to depend on a package from another registry, you add that
18+ in to your ` Cargo.toml ` :
19+
20+ ``` toml
21+ [dependencies ]
22+ other-crate = { version = " 1.0" , registry = " my-registry" }
23+ ```
24+
25+ To learn more, check out the [ registries section of the Cargo
26+ book] ( https://doc.rust-lang.org/nightly/cargo/reference/registries.html ) .
Original file line number Diff line number Diff line change 1+ # TryFrom and TryInto
2+
3+ Initially added: ![ Minimum Rust version: 1.34] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.34-brightgreen.svg )
4+
5+ The [ ` TryFrom ` ] ( ../../std/convert/trait.TryFrom.html ) and
6+ [ ` TryInto ` ] ( ../../std/convert/trait.TryInto.html ) traits are like the
7+ [ ` From ` ] ( ../../std/convert/trait.From.html ) and
8+ [ ` Into ` ] ( ../../std/convert/trait.Into.html ) traits, except that they return a
9+ result, meaning that they may fail.
10+
11+ For example, the ` from_be_bytes ` and related methods on integer types take
12+ arrays, but data is often read in via slices. Converting between slices and
13+ arrays is tedious to do manually. With the new traits, it can be done inline
14+ with ` .try_into() ` :
15+
16+ ``` rust
17+ let num = u32 :: from_be_bytes (slice . try_into ()? );
18+ ```
You can’t perform that action at this time.
0 commit comments