Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: mojo/public/rust/src/bindings/util.rs

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/rust/src/bindings/run_loop.rs ('k') | mojo/public/rust/src/lib.rs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/rust/src/bindings/util.rs
diff --git a/mojo/public/rust/src/bindings/util.rs b/mojo/public/rust/src/bindings/util.rs
deleted file mode 100644
index 208a5d7a5f0ddc60a88092e786e63e242602a443..0000000000000000000000000000000000000000
--- a/mojo/public/rust/src/bindings/util.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-//! This module contains some useful functions for encoding.
-
-/// Given some size value, the size is aligned to some number in bytes.
-///
-/// Neither the size nor bytes may be zero (those are always aligned) and
-/// bytes must be a power of two (other alignments don't make sense).
-pub fn align_bytes(size: usize, bytes: usize) -> usize {
- debug_assert!(bytes != 0);
- debug_assert!((bytes & (!bytes + 1)) == bytes);
- (size + bytes - 1) & (!(bytes - 1))
-}
-
-/// Converts some number of bits into however many bytes are needed to
-/// represent that bit size.
-pub fn bits_to_bytes(bits: usize) -> usize {
- ((bits + 7) >> 3)
-}
-
-#[cfg(test)]
-mod tests {
- use super::align_bytes;
- use super::bits_to_bytes;
-
- #[test]
- fn check_align_bytes() {
- assert_eq!(align_bytes(12, 8), 16);
- assert_eq!(align_bytes(16, 4), 16);
- assert_eq!(align_bytes(1, 1), 1);
- }
-
- #[test]
- #[should_panic]
- fn check_bad_align_bytes() {
- assert_eq!(align_bytes(15, 7), 21);
- assert_eq!(align_bytes(2, 0), 0);
- }
-
- #[test]
- fn check_bits_to_bytes() {
- assert_eq!(bits_to_bytes(8), 1);
- assert_eq!(bits_to_bytes(0), 0);
- assert_eq!(bits_to_bytes(1), 1);
- assert_eq!(bits_to_bytes(21), 3);
- }
-}
« no previous file with comments | « mojo/public/rust/src/bindings/run_loop.rs ('k') | mojo/public/rust/src/lib.rs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698