Skip to content

Commit

Permalink
Backport Ref under v1.4.x's existing license
Browse files Browse the repository at this point in the history
This file is being re-released under BSD+PATENTS to match the existing
license in this old release branch, to avoid including a license change in a .z
release.

Active development of the HSL continues under the MIT license, as indicated by
the LICENSE file in the master branch. The 1.4.x series was the last release
under the old license; the use of BSD+PATENTS here is only due to
backporting.

refs #108
  • Loading branch information
fredemmott committed Jan 10, 2020
1 parent 5f6938a commit 3490970
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Ref.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?hh // strict
/*
* Copyright (c) 2004-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/

namespace HH\Lib;

/** Wrapper class for getting object (byref) semantics for a value type.
*
* This is especially useful for mutating values outside of a lambda's scope.
*
* In general, it's preferable to refactor to use return values or `inout`
* parameters instead of using this class - however, a `Ref` of a Hack array
* is generally preferable to a Hack collection - e.g. prefer `Ref<vec<T>>`
* over `Vector<T>`.
*
* `C\reduce()` and `C\reduce_with_key()` can also be used in some situations
* to avoid this class.
*/
final class Ref<T> {
<<__RxShallow>>
public function __construct(public T $value) {}
}

0 comments on commit 3490970

Please sign in to comment.