こんにちは、R&Dチームの齋藤(@aznhe21)です。 つい先日、初めてのiOSアプリを業務でリリースしました。 ちなみに私はiPhoneもMacも持ってません。どうしてこうなった
さて、本日、日本時間7/17(金)、Rust 1.45がリリースされました。 この記事ではRust 1.45での変更点を詳しく紹介します。 なお、この記事は公式リリースノートをベースに、意訳・編集・追記をしています。
7/17は「もはや戦後ではない」で有名な経済白書が発表された日
- ピックアップ
- 変更点リスト
- 言語
- コンパイラ
- ライブラリ
- 安定化されたAPI
- Arc::as_ptr
- BTreeMap::remove_entry
- Rc::as_ptr
- rc::Weak::as_ptr
- rc::Weak::from_raw
- rc::Weak::into_raw
- str::strip_prefix
- str::strip_suffix
- sync::Weak::as_ptr
- sync::Weak::from_raw
- sync::Weak::into_raw
- char::UNICODE_VERSION
- Span::resolved_at
- Span::located_at
- Span::mixed_site
- unix::process::CommandExt::arg0
- その他
- 互換性メモ
- 内部の変更
- 関連リンク
- さいごに
- ライセンス表記
ピックアップ
個人的に注目する変更点を「ピックアップ」としてまとめました。 全ての変更点を網羅したリストは変更点リストをご覧ください。
手続きマクロが大半の場所で使えるようになった
これまで、手続きマクロ(macro_rules!で定義するのではなくプログラムとしてパース・変換できるマクロ)を関数の形で使うことが出来ませんでした。
Rust 1.45からはmacro_rules!と同じく様々な場所で使えるようになり、メタプログラミングがより高度化できるようになるのです。
// コマンドを実行して文字列として返すマクロのイメージ // 手続きマクロはプログラムとして実行されるので割と何でも出来る const BUILD_ENV = system!("cat /etc/redhat-release");
この機能を使った代表的なクレートとしてRocket *1があります。 このクレートは登場してから3年半もの間多くのNightly限定の機能に依存していましたが、 今回の機能安定化によってNightly限定の機能への依存が無くなり、ようやく安定Rustでも使えるようになります*2。
ちなみに、これまでもproc-macro-hackというクレートを使えば(擬似的に)手続きマクロを式として使えたのですが、
これは擬似的な実現である都合上recursion_limitの制限に引っ掛かります。
例えばfutures::select!マクロは内部的には手続きマクロとして実装されていますが、recursion_limitの制限を受けます。
Rust 1.45以降ならproc-macro-hackを外すことでこの制限から外れることが出来ます。
ただし、この機能を使うためにはRust 1.44以下を切り捨てる必要があり、
そしてfuturesにはサポートするRustの最低バージョン(MSRV)のポリシーが無いため、
futures::select!がrecursion_limitから解放される時期は不明のようです。
rustdocへの細かな改善
cargo docなどで生成されるrustdocが少し改善されました。
#[deprecated]の付いたアイテムには、従来のメッセージに加えて絵文字👎が付くようになった- ~~打ち消し線~~が使えるようになった
rust-analyzerの紹介
Rust 1.45とは直接関係ありませんが、目覚ましい進化を遂げているrust-analyzerの最近の変更点を紹介します。 決してネタ切れではありません。
知らない方向けに説明すると、rust-analyzerはRust向けのLanguage Serverで、VSCodeや(Neo)vim、Emacsなど多くのエディタで共通して使えるIDE基盤です。
以前からあるrlsとは異なり、rustcとコードを共通化・ライブラリ化して再利用性を高めることで、より良いIDEの開発を可能にしている他、
補完だけでなく識別子のrenameやimplを追加するコマンドなど、IDEに必要な機能が多く実装されています。
rustupでインストール出来るようになった
Nightlyではrustup component add --toolchain nightly rust-analyzer-previewとすることでrust-analyzerをインストール出来るようになりました。
ただし、現時点ではまだGitHubからインストールすることを推奨しているようです。
Cargo.tomlを自動でリロードするようになった
コードを書いている際に、クレートが不足していることに気付いてCargo.tomlを編集することはよくありますが、 そうすると、エディタを再起動するかrust-analyzerを再起動するまでその変更を適用することはできませんでした。
最近の更新で、Cargo.tomlに変更がある場合は自動でリロードすることが出来るようになりました。 ブログのgifを見ると、即座に変更が適用されていることが分かります。
なお、これを無効にするにはrust-analyzer.cargo.autoreloadをfalseに設定します。
VSCodeであれば、自動リロードを無効にしてもステータスバーの項目をクリックすることで手動でリロード出来ます。
それ以外のエディタでも、rust-analyzer.reloadWorkspaceコマンドを実行することで手動でリロード出来ます。
変更点リスト
言語
- 範囲外の浮動小数点からの
asによる変換が、切り詰めによる変換であることが定義された。 以前は未定義とされていたが、どうしてもパフォーマンスが必要な場合は{f64, f32}::to_int_uncheckedを使って以前の挙動を再現することが出来る。 訳注:詳細はRust 1.44の深堀りを参照されたい mem::Discriminant<T>が、常にu64を使うのではなくTの判別用の型を使うようになった。 訳注:repr(u128)/repr(i128)な列挙型(Nightly限定)では判別用の値がu64よりも大きくなりうるため。 判別用の型=DiscriminantKind::Typeをユーザーがオーバーライドすることは出来ない- 関数の形で使う手続きマクロが、式やパターン、文の中で使えるようになった。
つまり、宣言マクロ(
macro_rules!)が使える場所すべてで手続きマクロが使えるようになったということ →ピックアップ
コンパイラ
target-featureフラグを用いて、個々のtarget-featureをオーバーライド出来るようになった。 例えば、-C target-feature=+avx2 -C target-feature=+fmaは-C target-feature=+avx2,+fmaと同義であるforce-unwind-tablesフラグを追加した。パニック戦略に関わらず常に巻き戻しテーブルを生成させることが出来るembed-bitcodeフラグを追加した。生成されたrlib中にLLVMのビットコードを含めさせることが出来る(デフォルトで有効)。 訳注:LTOを使わない場合、このフラグを無効化することでコンパイル時間の短縮、及び生成されるファイルのサイズ削減が出来る。 ただし、フラグの無効化と-C ltoを同時に指定した場合、コンパイラは処理を中止するcode-modelフラグに新しい値tinyを追加したmipsel-sony-pspへのTier 3サポート※を追加したthumbv7a-uwp-windows-msvcへのTier 3サポートを追加した
※RustのTierによるプラットフォームサポートの詳細はプラットフォームサポートのページを参照 ※訳注:英語ページ
ライブラリ
net::{SocketAddr, SocketAddrV4, SocketAddrV6}がPartialOrdとOrdを実装するようになったproc_macro::TokenStreamがDefaultを実装するようになったOsStringがFromStrを実装するようになったsaturating_negが全ての符号付き整数型に、saturating_absが全ての整数型に追加されたArc<T>とRc<T>がFrom<Cow<'_, T>>を、BoxがFrom<Cow<'_, T>>を実装するようになった。 この時、Tは[T: Copy]、str、CStr、OsStr、PathのいずれかであるBox<[T]>がFrom<[T; N]>を実装するようになったBitOrとBitOrAssignが全てのNonZero整数型で実装されるようになったfetch_minとfetch_maxが全てのアトミック整数型に追加されたfetch_updateが全てのアトミック整数型に追加されたcharとops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo}を組み合わせることでコードポイントの範囲をイテレートすることが出来るようになった
コードポイントのイテレートはこのように書ける。
fn main() { for ch in 'a'..='z' { print!("{}", ch); } println!(); // "abcdefghijklmnopqrstuvwxyz"が出力される }
安定化されたAPI
Arc::as_ptr
impl<T: ?Sized> Arc<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(this: &Arc<T>) -> *const T }
データへの生ポインタを提供する。
Arcは消費されず、参照カウントにも影響はない。このポインタはArcの強参照がある限り有効である。
BTreeMap::remove_entry
impl<K: Ord, V> BTreeMap<K, V> { #[stable(feature = "btreemap_remove_entry", since = "1.45.0")] pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)> where K: Borrow<Q>, Q: Ord + ?Sized, }
BTreeMapにキーが存在するならそのキーを削除し、保持されていたキーと値を返す。
キーはBTreeMapのキー型のどんな借用形式でも良いが、借用された値の順序はキー型の順序と一致している必要がある。
Rc::as_ptr
impl<T: ?Sized> Rc<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(this: &Rc<T>) -> *const T }
データへの生ポインタを提供する。
Rcは消費されず、参照カウントにも影響はない。このポインタはRcの強参照がある限り有効である。
rc::Weak::as_ptr
impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(&self) -> *const T }
Weak<T>が指すオブジェクトTへの生ポインタを返す。
ポインタは強参照が存在している限り有効である。ポインタはダングリングしているかもしれないし、アラインされていないかもしれないし、あるいはnullであるかもしれない。
rc::Weak::from_raw
impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub unsafe fn from_raw(ptr: *const T) -> Weak<T> }
into_rawで生成された生ポインタをWeak<T>に変換して戻す。
(あとでupgradeを呼び出して)強参照を得たり、Weak<T>をドロップすることで弱参照を減らしたりすることに使える。
このメソッドは弱参照の中から1つ所有権を奪う(ただし、弱参照を持たないnewで作られたポインタを除く)。
安全性
このポインタはinto_raw由来である必要があり、また潜在的に弱参照が生存している必要もある。
メソッドを呼び出す段階の強参照カウントは0でも良いが、弱参照カウントは非ゼロ、
またはダングリングした(newで生成された)Weak<T>由来である必要がある。
rc::Weak::into_raw
impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn into_raw(self) -> *const T }
Weak<T>を消費し、生ポインタに変換する。
このメソッドは弱参照をポインタに変換するが、元々の参照カウントは保持する。
そして、from_rawによってWeak<T>に戻すことが出来る。
対象のポインタにアクセスする際、as_ptrと同じ制約を受ける。
str::strip_prefix
#[lang = "str"] #[cfg(not(test))] impl str { #[must_use = "this returns the remaining substring as a new slice, \ without modifying the original"] #[stable(feature = "str_strip", since = "1.45.0")] pub fn strip_prefix<'a, P>(&'a self, prefix: P) -> Option<&'a str> where P: Pattern<'a>, }
接頭辞が削除された文字列のスライスを返す。
文字列がパターンprefixで始まる場合、接頭辞が削除された部分文字列をSomeで包んで返す。
trim_start_matchesとは異なり、一番最初に一致した部分だけが削除される。
もし文字列がprefixで始まらない場合、Noneを返す。
パターンには&strやchar、またはcharのスライス、あるいは文字がマッチするかを判断する関数またはクロージャを指定できる。
str::strip_suffix
#[lang = "str"] #[cfg(not(test))] impl str { #[must_use = "this returns the remaining substring as a new slice, \ without modifying the original"] #[stable(feature = "str_strip", since = "1.45.0")] pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str> where P: Pattern<'a>, <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>, }
接尾辞が削除された文字列のスライスを返す。
文字列がパターンsuffixで終わる場合、接尾辞が削除された部分文字列をSomeで包んで返す。
trim_end_matchesとは異なり、一番最後に一致した部分だけが削除される。
もし文字列がsuffixで終わらない場合、Noneを返す。
パターンには&strやchar、またはcharのスライス、あるいは文字がマッチするかを判断する関数またはクロージャを指定できる。
sync::Weak::as_ptr
impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(&self) -> *const T }
Weak<T>が指すオブジェクトTへの生ポインタを返す。
ポインタは強参照が存在している限り有効である。ポインタはダングリングしているかもしれないし、アラインされていないかもしれないし、あるいはnullであるかもしれない。
sync::Weak::from_raw
impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub unsafe fn from_raw(ptr: *const T) -> Weak<T> }
into_rawで生成された生ポインタをWeak<T>に変換して戻す。
(あとでupgradeを呼び出して)強参照を得たり、Weak<T>をドロップすることで弱参照を減らしたりすることに使える。
このメソッドは弱参照の中から1つ所有権を奪う(ただし、弱参照を持たないnewで作られたポインタを除く)。
安全性
このポインタはinto_raw由来である必要があり、また潜在的に弱参照が生存している必要もある。
メソッドを呼び出す段階の強参照カウントは0でも良いが、弱参照カウントは非ゼロ、
またはダングリングした(newで生成された)Weak<T>由来である必要がある。
sync::Weak::into_raw
impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn into_raw(self) -> *const T }
Weak<T>を消費し、生ポインタに変換する。
このメソッドは弱参照をポインタに変換するが、元々の参照カウントは保持する。
そして、from_rawによってWeak<T>に戻すことが出来る。
対象のポインタにアクセスする際、as_ptrと同じ制約を受ける。
char::UNICODE_VERSION
#[stable(feature = "unicode_version", since = "1.45.0")] pub const UNICODE_VERSION: (u8, u8, u8);
charやstrの中でUnicodeに関連するメソッドが基づいているUnicodeのバージョン。
Unicodeは定期的に新バージョンがリリースされ、それに伴い標準ライブラリのメソッドも更新される。
従って、charやstrのメソッドの振る舞いやUNICODE_VERSION定数の値も定期的に更新される。
また、このような変更は破壊的変更とは見做されない。
バージョン番号の体型は Unicode 11.0 or later, Section 3.1 Versions of the Unicode Standard で説明されている。
Span::resolved_at
impl Span { #[stable(feature = "proc_macro_span_resolved_at", since = "1.45.0")] pub fn resolved_at(&self, other: Span) -> Span }
selfと同じ行・列の情報で新しいスパンを生成する。ただし、シンボルとしてはotherで解決されたと見做される。
Span::located_at
impl Span { #[stable(feature = "proc_macro_span_located_at", since = "1.45.0")] pub fn located_at(&self, other: Span) -> Span }
selfと同じ名前で解決されたと見做される新しいスパンを生成する。ただし、行・列の情報はotherから引き継がれる。
Span::mixed_site
impl Span { #[stable(feature = "proc_macro_mixed_site", since = "1.45.0")] pub fn mixed_site() -> Span }
macro_rulesと同じ衛生性を表すスパンで、マクロの定義場所(ローカル変数やラベル、あるいは$crate)で解決されることもあれば、
マクロの呼び出し場所(その他すべて)で解決されることもある。
スパンの位置は呼び出し場所が元となる。
unix::process::CommandExt::arg0
#[stable(feature = "rust1", since = "1.0.0")] pub trait CommandExt { #[stable(feature = "process_set_argv0", since = "1.45.0")] fn arg0<S>(&mut self, arg: S) -> &mut Command where S: AsRef<OsStr>, }
実行ファイルの引数を設定する。
最初のプロセス引数であるargv[0]を、デフォルトの実行ファイルのパス以外に設定する。
その他
- rustdocのMarkdownでの打ち消し線がサポートされた。例えば
~~古い情報~~は「古い情報」となる。 →ピックアップ - rustdocの非推奨APIを示すメッセージに絵文字👎が出るようになった。 →ピックアップ
互換性メモ
- static変数をその値自身で初期化するのは不良動作であるためコンパイルエラーが発されるようになった
{f32, f64}::powiがWindowsでわずかに異なる値を返すようになった。 これは{f32, f64}::powiが用いるLLVMの組み込み関数の変更によるもの- rustdocのCLIの余分な終了コードが削除された。 これはドキュメント化されておらず、広く使われることを意図していないものだった。 rustdocが非ゼロの終了コードを返すことに変わりはない
内部の変更
関連リンク
さいごに
次のRust 1.46は2020/8/28(金)に予定されています。
今度こそ定数関数内でif/matchやループが使えるようになりそうな他、
#[track_caller]によってパニック時のログに不要な関数が出ないように出来るようになりそうです。
オプティムでは、オプティムの急成長を支えるエンジニアを募集しています。
ライセンス表記
- この記事はApache 2/MITのデュアルライセンスで公開されている公式リリースノートを翻訳・追記をしています
- 冒頭の画像中にはRust公式サイトで配布されているロゴを使用しており、 このロゴはMozillaによってCC-BYの下で配布されています
- 冒頭の画像はいらすとやさんの画像を使っています。いつもありがとうございます
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.