1// Copyright 2006 The Android Open Source Project
2// Copyright 2020 Yevhenii Reizner
3//
4// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6
7use crate::LengthU32;
8
9// Perfectly safe.
10pub const LENGTH_U32_ONE: LengthU32 = unsafe { LengthU32::new_unchecked(1) };
11
12pub fn left_shift(value: i32, shift: i32) -> i32 {
13 ((value as u32) << shift) as i32
14}
15
16pub fn left_shift64(value: i64, shift: i32) -> i64 {
17 ((value as u64) << shift) as i64
18}
19
20pub fn bound<T: Ord + Copy>(min: T, value: T, max: T) -> T {
21 max.min(value).max(min)
22}
23