text
stringlengths
8
4.13M
use super::super::gl; use std::os::raw::c_void; #[derive(Copy, Clone, Debug)] pub struct TextureFormat { level: gl::GLint, internal_format: gl::GLenum, format: gl::GLenum, type_: gl::GLenum, } impl Default for TextureFormat { fn default() -> Self { Self { level: 0, ...
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
pub use VkPrimitiveTopology::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkPrimitiveTopology { VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0, VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1, VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3, VK_PRIMITIVE_TOPOLOGY_TR...
use itertools::Itertools; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn read_input(path: &Path) -> Vec<u64> { let file = File::open(path).unwrap(); let lines = io::BufReader::new(file).lines(); let mut res = Vec::new(); for line in lines { res.push(line.unwrap().parse...
use std::process::Command; use std::io::{self, Write}; use std::error::Error; fn main() -> Result<(), Box<dyn Error>>{ println!("Welcome to dummy command executor v1!"); loop { print!("$ "); io::stdout().flush().expect("fail to flush the stdout"); let mut inp = String::new(); io...
mod sample; mod acc; mod study_gl; mod etl; mod positionality; extern crate permutohedron; const DATA_ARRAY_LEN: usize = 13; fn main() { let mut best_candidate = vec![-30, -23, 0, 30, 76, 78, 80, 95, 100, 114]; let max_count = study_gl::max_perm_count(&mut best_candidate); println!("Max count: {:?}", max...
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn ldexpf(x: f32, n: i32) -> f32 { super::scalbnf(x, n) }
use std::{ fmt::Display, net::SocketAddrV4, sync::{ atomic::{AtomicU16, Ordering}, Arc, }, }; // These port numbers are chosen to not collide with a development ioxd server // running locally. static NEXT_PORT: AtomicU16 = AtomicU16::new(8090); // represents port on localhost to bind /...
use crate::{ biginteger::BigInteger384 as BigInteger, field_new, fields::{ fp6_3over2::{Fp6, Fp6Parameters}, Field, Fp2Parameters, }, }; use crate::fields::bn_382::{ fq::Fq, fq2::{Fq2, Fq2Parameters}, }; pub type Fq6 = Fp6<Fq6Parameters>; #[derive(Clone, Copy)] pub struct Fq6P...
#[repr(C)] #[derive(Debug)] pub struct VkDispatchIndirectCommand { pub x: u32, pub y: u32, pub z: u32, }
use super::Symbol; use crate::find_usages::{AddressableUsage, UsageMatcher}; use crate::process::subprocess::exec; use crate::tools::gtags::GTAGS_DIR; use dumb_analyzer::resolve_reference_kind; use rayon::prelude::*; use std::io::{Error, ErrorKind, Result}; use std::path::{PathBuf, MAIN_SEPARATOR}; use subprocess::{Exe...
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn...
use arrayvec::ArrayVec; use num_bigint::BigUint; use num_traits::identities::Zero; /// Type for indexing leaves of a sparse merkle tree pub trait LeafIndex { /// Path from root to leaf // TODO: Return type can be arrayvec? fn to_leaf_path(&self, arity: u8, tree_depth: usize) -> Vec<u8>; } /// When sparse ...
// auto generated, do not modify. // created: Wed Jan 20 00:44:03 2016 // src-file: /QtQuick/qsgflatcolormaterial.h // dst-file: /src/quick/qsgflatcolormaterial.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end //...
extern crate santa17; use santa17::*; fn main() { let (g1, g2) = construct_graph(); let ps = read_solution(&std::env::args().nth(1).unwrap()); let mut count = vec![0; N]; let mut err = false; for i in 0..N { if ps[i] == !0 { err = true; } else { count[ps[i]] += 1; } } if err { println!("mismatch!...
#[doc = "Reader of register ADC3R"] pub type R = crate::R<u32, super::ADC3R>; #[doc = "Writer for register ADC3R"] pub type W = crate::W<u32, super::ADC3R>; #[doc = "Register ADC3R `reset()`'s with value 0"] impl crate::ResetValue for super::ADC3R { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
//! `builtins` contains built-in function definitions. use crate::interpreter::{Environment, InterpreterError, Value}; use std::rc::Rc; /// Add the built-in functions (defined in this module – `builtin`) to an `Environment`. pub fn add_builtins_to_environment(env: &mut Environment) { env.set("+".to_string(), Rc::...
//! Linux auxv support, for Mustang. //! //! # Safety //! //! This uses raw pointers to locate and read the kernel-provided auxv array. #![allow(unsafe_code)] use crate::backend::c; use crate::backend::elf::*; #[cfg(feature = "param")] use crate::ffi::CStr; use core::ffi::c_void; use core::mem::size_of; use core::ptr:...
mod me_state_machine; pub mod rpc_server;
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtCore/qshareddata.h // dst-file: /src/core/qshareddata.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin =>...
use super::*; use crate::{prefix_type::PrefixRefTrait, utils::leak_value}; /// The root module of a dynamic library, /// which may contain other modules,function pointers,and static references. /// /// /// # Examples /// /// For a more in-context example of a type implementing this trait you can look /// at either th...
use atoms::{Location, Token}; use traits::HasLocation; /// /// A literal that is bound by some symbol. /// ie. a String literal "hello, world" or /// a char literal '. /// #[derive(Debug)] pub struct SymbolBoundLiteral { /// /// The token used as the left-hand bound /// of this token. /// pub open_...
use std::fmt::Display; use async_trait::async_trait; use crate::{ error::{DynError, ErrorKind, SimpleError}, file_classification::FilesForProgress, PartitionInfo, }; use super::PostClassificationPartitionFilter; #[derive(Debug)] pub struct PossibleProgressFilter { max_parquet_bytes: usize, } impl P...
use std::f64::EPSILON; use crate::{ config, material::Material, ray::Ray, sdf::SDF, traits::{HitRecord, Hittable}, P3, V3, }; use cgmath::{EuclideanSpace, InnerSpace, Matrix4, Transform, Transform3, Vector3}; use std::cell::Cell; use std::ops::Neg; #[derive(Debug)] pub enum ObjectData { Sp...
use P22::range; pub fn main() { println!("{:?}", range(4, 9)); }
use std::fs; use std::io; use std::num; use std::io::Read; use std::collections::HashSet; #[derive(Debug)] enum CliError { IoError(io::Error), ParseError(num::ParseIntError) } impl From<io::Error> for CliError { fn from(error: io::Error) -> Self { CliError::IoError(error) } } impl From<num::P...
use super::Material; use crate::{Color, Ray, Vec3}; pub struct Metal { albedo: Color, fuzz: f64, } impl Metal { pub fn new(albedo: Color, fuzz: f64) -> Self { Self { albedo, fuzz } } } impl Material for Metal { fn scatter( &self, ray: &crate::Ray, rec: &mut crate::...
//use std::io::{Read, Seek}; // //pub struct ObjMeshLoader<R: Read + Seek> { // //} // //impl<R: Read + Seek> ObjMeshLoader<R> { // //}
use std::collections::HashMap; fn main() { let (x, y) = day_3_part_1(347991); println!("{}", x.abs() + y.abs()); day_3_part_2(347991); } // Beware, math ahead. // Abandon all hope ye who enter here. // Calculates the coordinates for any number in the spiral // // 17 16 15 14 13 // 18 5 4 3 ...
use crate::rand::Rng; use std::cmp::Ordering; #[macro_use] extern crate text_io; extern crate rand; fn main() { println!("Guess the number!"); let secret_number: u32 = rand::thread_rng().gen_range(1, 100); println!("Please Input your guess: "); loop { let guess: u32 = read!(); println...
use clap::{App, Arg, ArgMatches}; pub fn match_args<'a>() -> ArgMatches<'a> { return App::new("sup") .version("0.1") .author("Mahmoud G. <mhmoudgmal.89@gmail.com>") .about("TODO://") .arg( Arg::with_name("stackfile") .short("f") .long("sta...
/* * @lc app=leetcode.cn id=563 lang=rust * * [563] 二叉树的坡度 * * https://leetcode-cn.com/problems/binary-tree-tilt/description/ * * algorithms * Easy (47.23%) * Total Accepted: 2.5K * Total Submissions: 5.3K * Testcase Example: '[1,2,3]' * * 给定一个二叉树,计算整个树的坡度。 * * 一个树的节点的坡度定义即为,该节点左子树的结点之和和右子树结点之和的差的绝对值...
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use failure::{bail, Error}; use fidl_fuchsia_bluetooth_gatt::{ self as gatt, AttributePermissions, Characteristic, Descriptor, LocalServiceDelegate...
// The MIT License (MIT) // // Copyright (c) 2013 Jeremy Letang (letang.jeremy@gmail.com) // // 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 limitati...
extern crate winapi; extern crate widestring; extern crate chrono; use std::mem; use std::thread; use std::time::Duration; use std::ptr; use std::collections::HashMap; use chrono::prelude::*; use winapi::um::errhandlingapi; use winapi::um::eventtrace; use widestring::WideCString; use winapi::shared::winerror; const...
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use spiro_sys::{self, bezctx}; use std::os::raw::c_int; macro_rules! spiro_cp { ({$x:literal, $y:literal, $ty:literal}) => { spiro_sys::spiro_cp { x: $x as f64, y: $y as f64, ty: $ty as i8 } } } unsafe extern "C" fn println_moveto(_bc: *mut bezctx, x: f64, y...
use std::net::UdpSocket; const serv_addr: &str = "127.0.0.1:8000"; const cli_addr: &str = "0.0.0.0:0"; fn main() { let mut socket = UdpSocket::bind(cli_addr).unwrap(); let mut buf = [4; 10]; socket.send_to(&buf, serv_addr); }
use const_regex::match_regex; const fn is_star_wars<const N: usize>(subtitle: &[u8; N]) -> bool { let mut bytes = *subtitle; let mut i = 0; while i < bytes.len() { bytes[i] = bytes[i].to_ascii_lowercase(); i += 1; } match_regex!("m | [tn]|b", &bytes) } fn main() { dbg!(is_sta...
extern crate juniper; extern crate sys_info; extern crate libc; use self::libc::timeval; use self::juniper::Context; pub enum ByteUnit { KB, MB, GB, TB } pub enum CycleUnit { MHz, GHz } fn get_byte_conversion(unit: Option<ByteUnit>) -> u64 { match unit { Some(u) => match u { ...
#[derive(Debug, Clone, Copy)] pub enum BinaryOp { Add, Sub, Mul, Div, } #[derive(Debug, Clone)] pub enum Term { Num(f64), Binary(Box<Term>, BinaryOp, Box<Term>), } impl Term { pub fn calc(&self) -> f64 { use BinaryOp::*; use Term::*; match &self { Num(num) => *num, Binary(left, A...
/** By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? */ #[cfg(test)] mod tests { use super::*; #[test] fn test() { assert_eq!(get_prime(6), 13); assert_eq!(get_prime(10001), 104743); } } pub fn get_p...
#![cfg(test)] use std::str; use collectxyz::nft::{Config, Coordinates, ExecuteMsg, InstantiateMsg, QueryMsg, XyzExtension}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{BankMsg, Binary, Coin, DepsMut, StdError, Uint128}; use serde_json::json; use crate::contract::{execute, i...
use crate::map_head::MapHead; use crate::map_type::MapType; use crate::map::Map; use crate::rlew_reader::RlewReader; use std::io::Read; use std::io::Cursor; use crate::plane::Plane; pub struct MapBuilder { map_head: MapHead, //map_type: MapType data: Vec<u8> } impl MapBuilder { pub fn new(map_head: Ma...
#[macro_use] extern crate nom; pub(crate) mod helpers; pub(crate) mod parser; pub(crate) mod structs; use crate::parser::elm; use crate::structs::{ElmCode, ElmModule, Function, Type, TypeOrFunction}; use hashbrown::HashSet; #[derive(Debug, Clone)] pub enum ElmExport { Function { name: String, typ...
use crate::macos::keyboard::Keyboard; use crate::rdev::{Button, Event, EventType}; use cocoa::base::id; use core_graphics::event::{CGEvent, CGEventFlags, CGEventTapLocation, CGEventType, EventField}; use lazy_static::lazy_static; use std::convert::TryInto; use std::os::raw::c_void; use std::sync::Mutex; use std::time::...
//! The floating panel that displays the sidebearings, advance, and other //! glyph metrics use druid::widget::{prelude::*, Controller, Flex}; use druid::{FontDescriptor, FontFamily, LensExt, WidgetExt}; use crate::data::{EditorState, GlyphDetail, Sidebearings}; use crate::widgets::{EditableLabel, GlyphPainter}; use ...
use std::collections::HashMap; use std::fmt; #[derive(Clone, Eq, PartialEq, Hash)] struct Tile(Vec<Vec<bool>>, u64); impl Tile { fn at(&self, mut x: usize, mut y: usize, transform: u8) -> bool { if (transform & 0x1) == 0x01 { std::mem::swap(&mut x, &mut y); } if (transform & 0x...
use block_modes::BlockModeError; use derive_more::Display; use failure::Backtrace; use failure::Fail; use std::io; use std::path::{Path, PathBuf}; use std::str::Utf8Error; use std::string::FromUtf8Error; use ini; use std::borrow::Cow; #[derive(Debug, Fail, Display)] pub enum Error { #[display(fmt = "Failed to dese...
pub mod checksum; pub mod keys; pub mod name; pub mod numeric; pub mod permission; pub mod serialize; pub mod time; pub use checksum::*; pub use keys::*; pub use name::*; pub use numeric::*; pub use permission::*; pub use serialize::*; pub use time::*;
use std::ffi::{CStr, NulError}; use std::error; use std::fmt; use std::str; use libc::c_int; use {raw, ErrorCode}; /// A structure to represent errors coming out of libgit2. #[derive(Debug)] pub struct Error { klass: c_int, message: String, } impl Error { /// Returns the last error, or `None` if one is n...
#[derive(Clone)] pub struct VM { initial_program: Vec<i64>, program: Vec<i64>, program_pos: usize, relative_base: i64, input: Vec<i64>, input_pos: usize, output: Vec<i64>, output_pos: usize, } #[derive(Debug, Eq, PartialEq)] pub enum StepResult { Continue, Exit, InputRequire...
// This experiment helped me learn about the ndarray crate, which is a very // Rust-y way to re-implement numpy. // // To experiment with ndarray, I implemented a batched outer product in three // different ways. The batched outer product takes an input of shape (..., Z) // and outputs an input of shape (..., Z, Z), wh...
//! Constant Q Transform //! //! This is a frequency transform on time-series data. //! It's like a Fourier transform, except that the bins are //! logarithmically spaced rather than linearly spaced. //! Humans perceive pitch in a similar way. //! Therefore, the CQT is useful for musical analysis. pub mod window; use ...
use proconio::input; fn main() { input! { a: u64, b: u64, c: u64, d: u64, e: u64, f: u64, }; let mo: u64 = 998244353; let (a, b, c, d, e, f) = (a % mo, b % mo, c % mo, d % mo, e % mo, f % mo); let x = a * b % mo * c % mo; let y = d * e % mo * f %...
//! The IPC is a bi-directional communication channel between the broker and sandbox //! //! Permitted calls are executed by the broker and results returned to the sandbox //! //! The following commands are defined: //! * ping - Return "pong" //! * open - Check whether permitted by the policy and return an fd // NOTE:...
//! Handle network connections for a varlink service #![allow(dead_code)] use crate::error::*; use chainerror::*; //#![feature(getpid)] //use std::process; use std::io::{BufRead, BufReader, Read, Write}; use std::net::{Shutdown, TcpListener, TcpStream}; use std::process; use std::sync::{mpsc, Arc, Mutex, RwLock}; use...
#[doc = "Reader of register WRPROT2"] pub type R = crate::R<u32, super::WRPROT2>; #[doc = "Reader of field `WRPROT2`"] pub type WRPROT2_R = crate::R<u16, u16>; impl R { #[doc = "Bits 0:15 - Write Protection"] #[inline(always)] pub fn wrprot2(&self) -> WRPROT2_R { WRPROT2_R::new((self.bits & 0xffff) ...
use crate::connection::ConnectOptions; use crate::error::Error; use crate::postgres::{PgConnectOptions, PgConnection}; use futures_core::future::BoxFuture; use log::LevelFilter; use std::time::Duration; impl ConnectOptions for PgConnectOptions { type Connection = PgConnection; fn connect(&self) -> BoxFuture<'...
//! A wrapper around TCP channels that Noria uses to communicate between clients and servers, and //! inside the data-flow graph. At this point, this is mostly a thin wrapper around //! [`async-bincode`](https://docs.rs/async-bincode/), and it might go away in the long run. use std::borrow::Borrow; use std::collection...
fn main() { let v = vec![1, 2, 3, 4]; let sum: i32 = v.iter().map(|x| x*x).sum(); println!("{}", sum); }
use crate::macros::Storage; use crate::shared::Description; use crate::Spanned; use runestick::{Source, SpannedError}; use thiserror::Error; error! { /// An error during resolving. #[derive(Debug, Clone)] pub struct ResolveError { kind: ResolveErrorKind, } } impl ResolveError { /// Constru...
extern crate rand; use rand::{random}; use std::time::Instant; use std::io::{Write, Result}; use std::fs::File; mod hitable; use hitable::{Hitable, HitRecord}; mod hitablelist; use hitablelist::HitableList; mod vec3; use vec3::Vec3; mod ray; use ray::Ray; mod sphere; use sphere::Sphere; mod camera; mod material...
use eosio::{ AccountName, BlockNum, BlockNumOrId, ScopeName, SymbolCode, TableName, }; use structopt::StructOpt; /// Retrieve various items and information from the blockchain #[derive(StructOpt, Debug)] pub enum Get { /// Get current blockchain information Info, /// Retrieve a full block from the bloc...
use super::*; use rand::{Rng, thread_rng}; use std::fmt; use std::fmt::Display; use std::collections::HashSet; #[derive(Debug, Clone)] pub struct Player { pub food: usize, pub fields: usize, pub grains: usize, pub vegetables: usize, pub wood: usize, pub clay: usize, pub reed: usize, pub...
#[doc = "Reader of register IF2MCTL"] pub type R = crate::R<u32, super::IF2MCTL>; #[doc = "Writer for register IF2MCTL"] pub type W = crate::W<u32, super::IF2MCTL>; #[doc = "Register IF2MCTL `reset()`'s with value 0"] impl crate::ResetValue for super::IF2MCTL { type Type = u32; #[inline(always)] fn reset_va...
use crate::algebra::FloatLike; use crate::collection::id_map::IdMap; use std::marker::PhantomData; #[derive(Clone, Debug)] struct Dist<W> { pub forward: W, forward_cause: Option<CId>, pub backward: W, backward_cause: Option<CId>, } impl<W: FloatLike> Dist<W> { fn default() -> Self { Dist { ...
//! Tests for `#[derive(ScalarValue)]` macro. use juniper::{DefaultScalarValue, ScalarValue}; use serde::{Deserialize, Serialize}; mod trivial { use super::*; #[derive(Clone, Debug, Deserialize, PartialEq, ScalarValue, Serialize)] #[serde(untagged)] pub enum CustomScalarValue { #[value(as_flo...
use super::constants; use rlua::{Lua, Result, Table}; pub struct ClassProxyBuilder<'lua>(&'lua Lua, Table<'lua>); impl<'lua> ClassProxyBuilder<'lua> { pub fn create(lua: &'lua Lua, table: Table<'lua>) -> ClassProxyBuilder<'lua> { return ClassProxyBuilder(lua, table); } pub fn build(self, mt: Tabl...
//! # my-pretty-failure //! //! [![Build Status](https://travis-ci.org/AlbanMinassian/my-pretty-failure.svg?branch=master)](https://travis-ci.org/AlbanMinassian/my-pretty-failure) //! [![codecov](https://codecov.io/gh/AlbanMinassian/my-pretty-failure/branch/master/graph/badge.svg)](https://codecov.io/gh/AlbanMinassian/...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { _reserved0: [u8; 4usize], #[doc = "0x04 - peripheral mode configuration register"] pub pmcr: PMCR, #[doc = "0x08 - external interrupt configuration register 1"] pub exticr1: EXTICR1, #[doc = "0x0c - external interrupt configuration...
// Copyright 2022 Datafuse Labs. // // 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 ...
//! Field guards use crate::{Context, Result}; /// Field guard /// /// Guard is a pre-condition for a field that is resolved if `Ok(())` is /// returned, otherwise an error is returned. #[async_trait::async_trait] pub trait Guard { /// Check whether the guard will allow access to the field. async fn check(&se...
//! # Documentation //! //! This module contains markdown conversions of the long-form PDF documentation //! available on <https://www.openexr.com>, giving tutorial- and white-paper- //! style articles on all aspects of the OpenEXR library. //! //! * [Reading and Writing Image Files](crate::doc::reading_and_writing_ima...
use advent::helpers; use anyhow::{Context, Result}; use itertools::Itertools; fn parse_bus_id_and_minutes(s: &str) -> (u64, Vec<Option<u64>>) { let mut lines = s.trim().lines(); let target_timestamp = lines .next() .expect("No first line") .parse::<u64>() .expect("Invalid initia...
#![warn( // Harden built-in lints missing_copy_implementations, missing_debug_implementations, // Harden clippy lints clippy::cargo_common_metadata, clippy::clone_on_ref_ptr, clippy::dbg_macro, clippy::decimal_literal_representation, clippy::float_cmp_const, clippy::get_unwrap, ...
#[doc = "Reader of register MACATSNR"] pub type R = crate::R<u32, super::MACATSNR>; #[doc = "Reader of field `AUXTSLO`"] pub type AUXTSLO_R = crate::R<u32, u32>; impl R { #[doc = "Bits 0:30 - Auxiliary Timestamp"] #[inline(always)] pub fn auxtslo(&self) -> AUXTSLO_R { AUXTSLO_R::new((self.bits & 0x7...
use std::collections::HashMap; use petgraph::Graph; use petgraph::graph::NodeIndex; use super::graph::{Node, Edge}; mod longest_path; pub trait RankingModule { fn call(&self, graph: &Graph<Node, Edge>) -> HashMap<NodeIndex, usize>; } pub struct LongetPathRanking {} impl LongetPathRanking { pub fn new() -> L...
use crate::nibbles::Nibbles; use std::mem; #[derive(Debug, Clone, Eq, PartialEq)] pub enum Node { Empty, Leaf(LeafNode), Extension(ExtensionNode), Branch(BranchNode), Hash(HashNode), } impl Node { pub fn swap(&mut self, mut n: Node) -> Node { mem::swap(self, &mut n); n } ...
use material; use ray::Ray; use vec3::Vec3; //#[derive(Copy,Clone)] pub struct HitRecord { pub t: f32, pub p: Vec3, pub normal: Vec3, pub material: Box<dyn material::Material>, } impl HitRecord { pub fn new() -> HitRecord { HitRecord { t: 0.0, p: Vec3::new(), ...
#[doc = r"Value read from the register"] pub struct R { bits: u32, } impl super::_3_FLTSTAT1 { #[doc = r"Reads the contents of the register"] #[inline(always)] pub fn read(&self) -> R { R { bits: self.register.get(), } } } #[doc = r"Value of the field"] pub struct PWM_3_F...
// Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::account::{Account, AccountContext}; use crate::common::AccountLifetime; use crate::inspect; use account_common::{AccountManagerError, LocalAccou...
use maat_graphics::math; use crate::{GenericObject, CollisionInfo}; pub fn collide_dynamic_with_dynamic(dyn_objects_a: &mut Vec<Box<dyn GenericObject>>, dyn_objects_b: &mut Vec<Box<dyn GenericObject>>) { for i in 0..dyn_objects_a.len() { for j in 0..dyn_objects_b.len() { ...
#![cfg(test)] /// Constructs an [crate::expression::arithmetic::Expr::VarRef] expression. #[macro_export] macro_rules! var_ref { ($NAME: literal) => { $crate::expression::Expr::VarRef($crate::expression::VarRef { name: $NAME.into(), data_type: None, }) }; ($NAME: li...
use std::fmt; #[derive(Debug, PartialEq, Clone)] pub enum Token { Add, Subtract, Multiply, Divide, Caret, LeftParen, RightParen, Num(f64), EOF, } #[derive(Debug, PartialEq, PartialOrd)] /// Defines all the OperPrec levels, from lowest to highest. pub enum OperPrec { DefaultZero...
pub fn heap_sort<T: PartialOrd>(v: &mut Vec<T>) -> &Vec<T> { if v.len() <= 1 { return v; } // build the binary heap from v for i in (0..v.len()/2).rev() { sink(v, i, v.len()) } // invariant: // [end+1..v.len()]: sorted; // [0..=end]: to be examined. let mut e...
use datafusion::common::tree_node::{TreeNode, TreeNodeRewriter}; use datafusion::error::Result as DataFusionResult; use datafusion::prelude::{lit, Expr}; use crate::ValueExpr; /// Rewrites an expression on `_value` as a boolean true literal, pushing any /// encountered expressions onto `value_exprs` so they can be mo...
use reqwest; error_chain! { types { Error, ErrorKind, ResultExt, Result; } foreign_links { Another(reqwest::Error); Io(::std::io::Error); } errors { WaitTooLong(t: u32) { description("queue is too long") display("queue is too long: '{}'", t)...
use crate::Peek; use boolinator::Boolinator; use proc_macro::TokenStream; use proc_macro2::{Ident, TokenTree}; use quote::{quote, ToTokens}; use std::fmt; use syn::buffer::Cursor; use syn::parse::{Parse, ParseStream, Result as ParseResult}; use syn::{Expr, Token}; pub struct HtmlProp { pub label: HtmlPropLabel, ...
// Copyright 2019 The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following // dis...
use matrix::Matrix4; use super::test::{Bencher, black_box}; #[test] fn matrix_equality() { let identity_1 = Matrix4::identity(); let mut identity_2 = Matrix4::identity(); assert!(identity_1 == identity_1); // self equality assert!(identity_1 == identity_2); // two identity matrices identity_2[0][...
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; #[derive( BorshSerialize, BorshDeserialize, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Default, )] pub struct BlockHeight(pub u64); impl From<u64> for BlockHeight { fn from(value: u64) -> Self...
// cli program arguments for main.rs pub mod cli; mod macros; mod command; mod commands; mod config; mod error; mod fs;
use utopia_core::math::Size; use nannou::{prelude::*, wgpu::Texture}; use utopia_nannou::{ interface::NannouInterface, widgets::{Flex, Image, LensExt, WidgetExt}, }; use utopia_text::widgets::text::Text; fn main() { NannouInterface::run(model) } struct MyState { text: &'static str, texture: Textu...
#[cfg(not(feature = "const_generics"))] use crate::Array; use crate::SmallVec; use core::{fmt, marker::PhantomData}; use serde::de::{Deserialize, SeqAccess, Visitor}; macro_rules! create_with_parts { ( <$($({$s_impl_ty_prefix:ident})? $s_impl_ty:ident$(: $s_impl_ty_bound:ident)?),*>, <$s_decl_ty:ident$(, {$s_d...
fn main() { let s = String::from("hello world"); let word = first_word(&s); // word will get the value 5 //s.clear(); // this empties the String, making it equal to "" println!("The first word is: {}", word); let my_string_literal = "hello world"; // first_word works ...
extern crate tokio; fn on_message(message: &str) { println!("> {}", message.to_string()); } #[tokio::main] async fn main() { let result = twitch_ts::start_instance("#battlechicken", on_message).await; if let Err(error) = result { println!("Exited with error: {}", error.to_string()); ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - "] pub reset: RESET, _reserved1: [u8; 3usize], #[doc = "0x04 - Bits 24-31 of `CTRL_SCRATCH`."] pub scratch3: SCRATCH3, _reserved2: [u8; 3usize], #[doc = "0x08 - Bits 16-23 of `CTRL_SCRATCH`."] pub scratch2: ...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "UI_Composition_Core")] pub mod Core; #[cfg(feature = "UI_Composition_Desktop")] pub mod Desktop; #[cfg(feature = "UI_Composition_Diagnostics")] pub mod Diagnostics; #[cfg(fea...
// Copyright 2021 Datafuse Labs. // // 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 agre...