Skip to content

Commit

Permalink
Add abs to cargo/private:cargo_utils.bzl
Browse files Browse the repository at this point in the history
  • Loading branch information
avdv committed Dec 12, 2024
1 parent 48ca1ab commit 9934f64
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cargo/private/cargo_utils.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
"""Utility functions for the cargo rules"""

load("//rust/platform:triple_mappings.bzl", "system_to_binary_ext")
load("//rust/private:utils.bzl", "abs")

# TODO: remove after dropping support for Bazel < 7 when `abs` is a global
def abs(value):
"""Returns the absolute value of a number.
Args:
value (int): A number.
Returns:
int: The absolute value of the number.
"""
if value < 0:
return -value
return value

def _resolve_repository_template(
*,
Expand Down

0 comments on commit 9934f64

Please sign in to comment.