text
stringlengths
8
4.13M
#[doc = "Reader of register REGION_TOP_LOW0"] pub type R = crate::R<u32, super::REGION_TOP_LOW0>; #[doc = "Reader of field `TOP_ADDRESS_LOW`"] pub type TOP_ADDRESS_LOW_R = crate::R<u32, u32>; impl R { #[doc = "Bits 12:31 - Top address bits"] #[inline(always)] pub fn top_address_low(&self) -> TOP_ADDRESS_LOW...
// 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 // disclai...
use std::fmt; use std::io; pub type LolbResult<T> = std::result::Result<T, LolbError>; #[derive(Debug)] pub enum LolbError { Message(&'static str), Owned(String), Io(io::Error), Acme(acme_lib::Error), H2(h2::Error), Http11Parse(httparse::Error), Http(http::Error), } use LolbError::*; impl...
use std::{ convert::{identity, TryInto}, ops::{Add, Deref, Shr, Sub}, }; use bitwriter::BitWriter; use crc::{Algorithm, Crc}; use crate::{ encoder::FixedResidual, headers::{BitsPerSample, BlockSize, MetadataBlockStreamInfo}, rice::{find_optimum_rice_param, get_rice_encoding_length, rice}, }; #[de...
struct Mathf; impl Mathf { // // Calculate the absolute value // fn abs(f: f32) -> f32 { f.abs() } // // Calculate the square root value // fn sqrt(f: f32) -> f32 { f.sqrt() } // // Calculate the cube root value // fn cbrt(f: f32) -> f32 { f.cbrt() } // //...
// Copyright 2017 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. //! System service for wireless networking // These features both have stable implementations and will become available on stable compilers // soon. They ...
use math::*; use num; use std::ops::*; use std::fmt::*; use rand::*; /// A 3d vector which consists of 3 fields x, y, z #[derive(Clone, Copy)] pub struct Vector3<T> { pub x: T, pub y: T, pub z: T } /// Convert vector3 to a matrix with 4 rows and 1 column. The vector is treated as a point and /// w is auto...
#[allow(unused_imports)] use std::{io, fmt}; fn main() { let mut num = String::new(); io::stdin().read_line(&mut num).expect("read error"); let num = num.trim().parse::<isize>().expect("parse error"); for i in 0..num { let mut temp = i; let mut gen = i; while 0<temp{ ...
use crate::gl_util; use crate::types::*; use crate::types::*; use regmach::dsp::types as rdt; use regmach::dsp::types::Display; use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys; use web_sys::{WebGl2RenderingContext, WebGlBuffer}; use rusttype::{point, FontCol...
use crate::{SecureChannelTrustInfo, TrustPolicy}; use ockam_core::Result; #[derive(Clone)] pub struct NoOpTrustPolicy; impl TrustPolicy for NoOpTrustPolicy { fn check(&self, _trust_info: &SecureChannelTrustInfo) -> Result<bool> { Ok(true) } }
extern crate trie; use std::fmt; use std::io::prelude::*; use std::fs::File; use trie::Node; fn main() { let mut f = match File::open("/usr/share/dict/words") { Ok(file) => file, Err(why) => panic!("Couldn't open /usr/share/dict/words: {:?}", why), }; let mut s = String::new(); if let E...
// Copyright 2017 PingCAP, Inc. // // 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 i...
use super::prelude::*; pub(crate) fn config(cfg: &mut web::ServiceConfig) { cfg.service(create_user) .service(show_users) .service(update_user) .service(delete_user) .service(login_user) .service(logout_user) .service(check_user); } #[post("/api/user/create")] async ...
use futures::stream::StreamExt; use serde_json::Value; use std::{env, error::Error}; use twilight_cache_inmemory::{InMemoryCache, ResourceType}; use twilight_embed_builder::{EmbedBuilder, EmbedFieldBuilder}; use twilight_gateway::{ cluster::{Cluster, ShardScheme}, Event, }; use twilight_http::Client as HttpClie...
#[cfg(test)] mod tests { use crate::aes_ecb::decrypt_ecb_byte_at_a_time; use crate::util::encrypt_with_prefix_and_suffix; use crate::util::generate_random_bytes; use crate::util::EncryptionType; use std::str; const UNKNOWN_STRING_BASE64: &str = "Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctd...
use super::*; pub fn expression() -> Expression { Expression { boostrap_compiler: boostrap_compiler, typecheck: typecheck, codegen: codegen, } } fn boostrap_compiler(_compiler: &mut Compiler) {} fn typecheck( resolver: &mut TypeResolver<TypecheckType>, _function: &TypevarFunct...
use ipnetwork::IpNetwork; use log::info; use rand::{ prelude::{IteratorRandom, SliceRandom}, thread_rng, }; use trust_dns_resolver::{ config::{NameServerConfig, ResolverConfig, ResolverOpts}, proto::rr::RecordType, IntoName, Name, Resolver, }; use crate::{ authority::{find_members, init_trust_d...
#[macro_use] extern crate serde_derive; pub mod proto;
pub fn modify_in_place<T, F: Fn(T) -> T>(mut v: Vec<T>, f: F) -> Vec<T> { let n = v.len(); if n > 0 { let mut t = v.pop().unwrap(); for i in 0 .. n - 1 { let x = std::mem::replace(&mut v[i], t); let y = f(x); t = std::mem::replace(&mut v[i], y); } ...
use std::path::PathBuf; use clap::{Parser, Subcommand, ValueEnum}; /// All-in-one tool for Apple dynamic HEIF wallpapers on GNU/Linux. #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] pub struct Args { /// Action subcommand #[command(subcommand)] pub action: Action, /// C...
/// HUST OS Lab4 Implementation in Rust /// extern crate libc; use std::{fs, io, path::PathBuf}; use std::env; use libc::c_char; use std::ffi::CString; extern { // fn hello(); #[allow(unused_variables)] fn print_stat(path: *const c_char); } fn main() -> io::Result<()>{ println!("Welcome to hust os lab...
use serde::{Deserialize, Serialize}; use super::api_framework::ApiFramework; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct Audio { mime: Vec<String>, api: Vec<ApiFramework>, ctype: Option<super::creative_subtype::Video>, dur: Option<i32>, adm: Option<String>, curl: Option<Strin...
#[doc = "Register `CR1` reader"] pub type R = crate::R<CR1_SPEC>; #[doc = "Register `CR1` writer"] pub type W = crate::W<CR1_SPEC>; #[doc = "Field `CPHA` reader - Clock phase"] pub type CPHA_R = crate::BitReader; #[doc = "Field `CPHA` writer - Clock phase"] pub type CPHA_W<'a, REG, const O: u8> = crate::BitWriter<'a, R...
pub mod charts; pub mod indicators;
use bytes::Bytes; use futures::stream::StreamExt; use std::marker::Unpin; use tokio::{ io::{self, AsyncRead, AsyncWrite}, join, sync::mpsc, }; use tokio_stream::Stream; use tokio_util::codec::{BytesCodec, FramedRead, FramedWrite}; use tracing::{debug, error}; use super::common::{stream_to_sender, stream_to...
// ๆจกๅ—๏ผŒๅ‡ฝๆ•ฐ้ƒฝ็”จ`pub`ๅ…ณ้”ฎๅญ—ๆ ‡่ฎฐไธบๅ…ฌๅ…ฑ๏ผŒๆ‰่ƒฝ่ขซๅค–้ƒจๅ‡ฝๆ•ฐๅผ•็”จ pub mod adder { pub fn exec(a: i32, b: i32) -> i32 { a + b } } #[cfg(test)] mod tests { // ๅ› ไธบtestsๆ˜ฏไธ€ไธชๆจกๅ—๏ผŒsuperๆ˜ฏๅผ•็”จๅค–้ƒจๆจกๅ—็š„ๆ–นๅผ // ๅผ•็”จ่ฟ‡็จ‹ไธญๅ‡ฝๆ•ฐๅ‰้ข่ฆๅŠ ไธŠmod ็š„ๅๅญ—ใ€‚ use super::*; #[test] fn add_test() { assert_eq!(adder::exec(2,3), 5); } } /// `self::`่กจ็คบๆœฌๆจก...
use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] #[serde(tag = "type", rename_all = "kebab-case")] pub enum Environment { Solid { tint: [f32; 3] }, Map { tint: [f32; 3], rotation: f32 }, } impl Default for Environment { fn default() -> Self { Se...
use std::io::{self, Write}; use serde_cbor::Value; pub fn pretty_print<W: Write>(output: &mut W, value: &Value, indent: u32, final_nl: bool) -> io::Result<()> { match value { Value::Null => write!(output, "null")?, Value::Bool(b) => write!(output, "{}", b)?, Value::Integer(i) => write!(out...
use core::any::Any; use crate::{Asset, AssetInfo, ResolvedPath, ResolverContext, ResolverError, WritableAsset}; mod wrapper; /// Enumeration of write modes for open_asset_for_write #[derive(Clone, Debug)] pub enum WriteMode { /// Open asset for in-place updates. If the asset exists, its contents /// will not...
//! Get info on files uploaded to Slack, upload new files to Slack. use rtm::{File, FileComment, Paging}; /// Deletes a file. /// /// Wraps https://api.slack.com/methods/files.delete #[derive(Clone, Debug, Serialize, new)] pub struct DeleteRequest { /// ID of file to delete. pub file: ::FileId, } /// Gets i...
use crate::eval::prelude::*; impl Eval<&ast::ExprIf> for ConstCompiler<'_> { fn eval( &mut self, expr_if: &ast::ExprIf, used: Used, ) -> Result<Option<ConstValue>, crate::CompileError> { let value = expr_if.condition.as_bool(self, used)?; if value { return s...
impl Solution { pub fn reconstruct_matrix(mut upper: i32, mut lower: i32, colsum: Vec<i32>) -> Vec<Vec<i32>> { let mut u = vec![0;colsum.len()]; let mut l = vec![0;colsum.len()]; for (i,e) in colsum.iter().enumerate() { if *e == 2 { upper = upper - 1; ...
#[macro_use] mod support; /// Helper to calculate the inner angle in the range [0, 2*PI) trait AngleDiff { type Output; fn angle_diff(self, other: Self) -> Self::Output; } macro_rules! impl_angle_diff { ($t:ty, $pi:expr) => { impl AngleDiff for $t { type Output = $t; fn ang...
use middle::middle::*; use mangle::Mangle; use context::Context; use stack::Stack; use code::{emit_block, emit_expression, sizeof_ty, size_name, eax_lo}; fn emit_allocator<'a, 'ast>(tydef: TypeDefinitionRef<'a, 'ast>) { emit!("section .text" ; "begin allocator"); emit!("ALLOC{}:", tydef.mangle()); // Pro...
/*! Module for most basic register handling Contains implementation for both "PC" version, used for testing, and the embedded version used for cross compiled apps, writing to addresses in memory. */ extern crate core; #[allow(dead_code)] pub mod raw_implementation { use ::core::ops::{BitAnd, B...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - GPIO port mode register"] pub gpiok_moder: GPIOK_MODER, #[doc = "0x04 - GPIO port output type register"] pub gpiok_otyper: GPIOK_OTYPER, #[doc = "0x08 - GPIO port output speed register"] pub gpiok_ospeedr: GPIOK_OSP...
use crate::problem_datatypes::Solution; use crate::problem_datatypes::DataPoints; use crate::problem_datatypes::Constraints; use crate::fitness_evolution::FitnessEvolution; use crate::arg_parser::ProgramParameters; use crate::problem_datatypes::population::Population; use crate::fitness_evaluation_result::FitnessEvalua...
#[doc = "Register `AHB1SECSR` reader"] pub type R = crate::R<AHB1SECSR_SPEC>; #[doc = "Field `DMA1SECF` reader - DMA1SECF"] pub type DMA1SECF_R = crate::BitReader; #[doc = "Field `DMA2SECF` reader - DMA2SECF"] pub type DMA2SECF_R = crate::BitReader; #[doc = "Field `DMAMUX1SECF` reader - DMAMUX1SECF"] pub type DMAMUX1SE...
use crate::{ DataSet, ItemSet, Support, closed::{ InitialSets, is_dup } }; /// Sequential implementation of the DCI-Closed algorithm. This is a straightforward /// implementation of the original algorithm from the paper. It uses only one CPU core. /// /// The returned collection will **always** have at least...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Write-only register. A read request returns all zeros."] pub ddrperfm_ctl: DDRPERFM_CTL, #[doc = "0x04 - DDRPERFM configurationl register"] pub ddrperfm_cfg: DDRPERFM_CFG, #[doc = "0x08 - DDRPERFM status register"] ...
use std::path::Path; use pahkat_client::{package_store::InstallTarget, PackageStore}; pub fn status( store: &dyn PackageStore, packages: &Vec<String>, target: InstallTarget, ) -> Result<(), anyhow::Error> { if packages.is_empty() { println!("No packages specified."); return Ok(()); ...
use std::convert::TryInto; use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, collections::LookupMap, ext_contract, near_bindgen, setup_alloc, log, BorshStorageKey, env, Promise, AccountId, json_types::{ValidAccountId, U64, U128}, }; setup_alloc!(); pub type TokenId = String; pu...
mod short_msg_kat_128; mod short_msg_kat_160; mod short_msg_kat_256; mod short_msg_kat_320;
#[doc = "Reader of register SPINLOCK6"] pub type R = crate::R<u32, super::SPINLOCK6>; impl R {}
#[macro_use] extern crate lambda_runtime as lambda; #[macro_use] extern crate serde_derive; #[macro_use] extern crate log; extern crate simple_logger; extern crate rss; use chrono::{DateTime, FixedOffset, Utc}; use lambda::error::HandlerError; use rss::{Channel, Item}; use scraper::{Html, Selector}; use std::error::Er...
use super::ExprDb; use nu_protocol::{ast::PathMember, CustomValue, ShellError, Span, Value}; use serde::{Deserialize, Serialize}; use sqlparser::ast::{Expr, Ident, ObjectName, SelectItem}; #[derive(Debug, Serialize, Deserialize)] pub struct SelectDb(SelectItem); // Referenced access to the native expression impl AsRe...
pub trait DecimalProps: Copy { // Total size (bits) const BITS: usize; // Exponent continuation field (bits) const EXPONENT_BITS: usize; // Coefficient continuation field (bits) const COEFFICIENT_BITS: usize; // Coefficient size (decimal digits) const COEFFICIENT_SIZE: usize; const M...
use quote::Ident; use std::io::Write; pub fn generate<W: Write>(modules: Vec<String>, out: &mut W) { let modules_tokens = modules.into_iter().map(|module| { let file_name = module.clone() + ".rs"; let module_ident = Ident::from(module.clone()); quote! { #[allow(non_camel_case_t...
#[doc = "Register `ICR` writer"] pub type W = crate::W<ICR_SPEC>; #[doc = "Field `FRAME_ISC` writer - Capture complete interrupt status clear"] pub type FRAME_ISC_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Field `OVR_ISC` writer - Overrun interrupt status clear"] pub type OVR_ISC_W<'a, REG, const ...
//! Defines how players interact with the game state. use std::collections::HashMap; use async_trait::async_trait; use futures::{future, TryFutureExt}; use tokio::stream::{StreamExt, StreamMap}; use tokio::sync::mpsc; use super::messages::{Action, GameError, Message}; #[async_trait] pub trait Interactions { ///...
use num::{BigInt, FromPrimitive}; fn is_prime(x: f64) -> bool { if x == 0.0 || x == 1.0 { return false } let range = x.powf(0.5); for i in 2..=range as i32 { if x % i as f64 == 0.0 { return false; } }; return true; } fn main() { let mut sum = BigInt::...
#![no_std] mod list; pub use list::SlotList;
extern crate iref; use iref::{Iri, IriRefBuf}; fn main() -> Result<(), iref::Error> { let base_iri = Iri::new("http://a/b/c/d;p?q")?; let mut iri_ref = IriRefBuf::new("g;x=1/../y")?; // non mutating resolution. assert_eq!(iri_ref.resolved(base_iri), "http://a/b/c/y"); // in-place resolution. iri_ref.resolve(b...
fn main() { println!("Run `cargo test` from main project folder"); }
mod explain; mod field_result; mod filter_result; mod search_result; mod search_result_with_doc; pub use explain::*; pub use field_result::*; pub use filter_result::*; pub use search_result::*; pub use search_result_with_doc::*;
fn ack(m: u64, n: u64) -> u64 { match (m, n) { (0, n) => n + 1, (m, 0) => ack(m - 1, 1), (m, n) => ack(m - 1, ack(m, n - 1)), } } fn main() { let a = ack(3, 4); println!("{}", a); // 125 }
#[doc = "Reader of register CLK_USB_SELECTED"] pub type R = crate::R<u32, super::CLK_USB_SELECTED>; impl R {}
use std::fs; use intcode::Computer; fn main() { let input: Vec<i64> = fs::read_to_string("input") .unwrap() .split(',') .map(|n| n.trim().parse().unwrap()) .collect(); let cpu = Computer::from(&input[..]); part1(cpu.clone()); } fn part1(mut cpu: Computer) { let outpu...
use crate::utils::{get_bit, get_bit_slice}; pub const KBD_ADDRESS: usize = 24_576; pub const SCR_ADDRESS: usize = 16_384; pub struct Computer { pub d_register: i16, pub a_register: i16, pub pc: i16, pub rom: [Option<i16>; 1000], pub memory: [i16; 24_577] } impl Computer { pub fn new() -> Comp...
use std::ops::{self, Add, Mul, Sub}; #[derive(Copy, Clone, Debug)] #[repr(C)] pub struct Vector4 { pub x: f64, pub y: f64, pub z: f64, pub w: f64, } impl Vector4 { pub const fn new(x: f64, y: f64, z: f64, w: f64) -> Self { Self { x, y, z, w } } pub const fn zero() -> Self { ...
use std::path::{Path, PathBuf}; use std::fs::{self, File}; use std::net::{ToSocketAddrs, TcpStream}; use std::ffi::CString; use std::os::unix::ffi::OsStrExt; use std::io::prelude::*; use std::io::BufReader; use std::thread::{self, JoinHandle}; use libc; struct Server { hostname: String, port: u16, prefix: ...
use crate::*; use std::path::PathBuf; pub fn eval_script(script: impl Into<String>, expected: Value) { let mut vm = VM::new(); match vm.run(PathBuf::from(""), &script.into(), None) { Ok(res) => { if res != expected { panic!("Expected:{:?} Got:{:?}", expected, res); ...
extern crate shred; use shred::{ReadExpect, SystemData, World}; struct MyRes; #[test] #[should_panic( expected = r#"Tried to fetch resource of type `MyRes`[^1] from the `World`, but the resource does not exist. You may ensure the resource exists through one of the following methods: * Inserting it when the wor...
#[derive(Clone, Default)] pub struct Bkdr; //TODO ๅ‚่€ƒjava็‰ˆๆœฌ่ฐƒๆ•ด๏ผŒๆ‰‹ๅŠจๆต‹่ฏ•ๅ„็ง้•ฟๅบฆkey๏ผŒhashไธ€่‡ด๏ผŒ้œ€่ฆ็บฟไธŠ็ปง็ปญ้ชŒ่ฏ fishermen impl super::Hash for Bkdr { fn hash(&mut self, b: &[u8]) -> u64 { let mut h = 0i32; let seed = 31i32; for c in b.iter() { h = h.wrapping_mul(seed).wrapping_add(*c as i32); ...
use framebuffer::{Color, Position, Pixel, Framebuffer}; use character_set::{ascii_to_glyph}; use mutex::Mutex; /// A global singleton allowing read/write access to the screen. pub struct Screen { inner: Option<Framebuffer>, position: Position, // TODO: make methods for this pub color: Color, pub hu...
pub fn texts() -> String { "1์‹œ๊ฐ„์˜ ๋†€์ด๊ฐ€ 1๋…„๊ฐ„์˜ ๋Œ€ํ™”๋ณด๋‹ค ๊ทธ ์‚ฌ๋žŒ์„ ๋” ์ž˜ ์•Œ๊ฒŒ ํ•ด์ค€๋‹ค. ๊ธฐ๋Šฅ์˜ ํ•œ๊ณ„๋ฅผ ์•Œ๊ธฐ ์œ„ํ•œ ์œ ์ผํ•œ ๋ฐฉ๋ฒ•์€ ๋ถˆ๊ฐ€๋Šฅ์˜ ์˜์—ญ์— ์‚ด์ง ๋ฐœ์„ ๋“ค์—ฌ๋†“์•„ ๋ณด๋Š” ๊ฒƒ. ๊ฐ€์žฅ ํฐ ์•ฝ์ ์€ ์•ฝ์ ์„ ๋ณด์ผ ๊ฒƒ์— ๋Œ€ํ•œ ๋‘๋ ค์›€์ด๋‹ค. ๊ฐ“ ํƒœ์–ด๋‚œ ์•„๊ธฐ๊ฐ€ ๋ฌด์Šจ ์“ธ๋ชจ๊ฐ€ ์žˆ๊ฒ ์Šต๋‹ˆ๊นŒ? ๊ฐ•ํ•œ ์ž๊ฐ€ ์ด๊ธฐ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์ด๊ธด ์ž๊ฐ€ ๊ฐ•ํ•œ ๊ฒƒ์ด๋‹ค. ๊ฐœ๊ฐ€ ๋‚  ๋ณด๊ณ  ์ง–๋Š”๋‹ค๊ณ  ๊ทธ ๊ฐœ๋ฅผ ์ฃฝ์ด์ง„ ์•Š๊ฒ ์†Œ. ๊ฐœ๊ฐ€ ์•„๋ฌด๋ฆฌ ์œ ์ฐฝํ•˜๊ฒŒ ์ง–์–ด๋„ ์ œ ๋ถ€๋ชจ๊ฐ€ ๊ฐ€๋‚œํ–ˆ์ง€๋งŒ ์ •์งํ–ˆ์—ˆ๋…ธ๋ผ๊ณ  ๋งํ•  ์ˆ˜ ์—†๋‹ค. ๊ฐœ์—๊ฒŒ ๋ฌผ๋ฆฐ ์ƒ์ฒ˜๋Š” ๊ฐœ๋ฅผ ์ฃฝ์ธ๋‹ค๊ณ  ์•„๋ฌผ์ง€ ์•Š๋Š”๋‹ค. ๊ฑฐ์ง“๊ณผ ๋”๋ถˆ์–ด ์ œ์ •์‹ ์œผ๋กœ ์‚ฌ๋А๋‹ˆ,...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - JEDEC JEP-106 compliant chip identifier."] pub chip_id: CHIP_ID, #[doc = "0x04 - Platform register. Allows software to know what environment it is running in."] pub platform: PLATFORM, _reserved2: [u8; 56usize], #[d...
#[doc = "Reader of register REGION_ID_ACCESS1"] pub type R = crate::R<u32, super::REGION_ID_ACCESS1>; #[doc = "Writer for register REGION_ID_ACCESS1"] pub type W = crate::W<u32, super::REGION_ID_ACCESS1>; #[doc = "Register REGION_ID_ACCESS1 `reset()`'s with value 0"] impl crate::ResetValue for super::REGION_ID_ACCESS1 ...
use logo_lib::command::basic::Forward; use logo_lib::{canvas::Image, Program, Rgba, Turtle}; fn main() { let program = Program::new(vec![Box::new(Forward::new(50.0))]); let (draw_queue, mut image) = Image::new(500, 500); let mut turtle = Turtle::new( (50.0, 50.0), ::std::f64::consts::FRAC...
use md5; fn compute_hash(input: &str, mask: u32) -> usize { for i in 0.. { let hash = md5::compute(format!("{}{}", input, i)); let val = ((hash[0] as u32) << 16) + ((hash[1] as u32) << 8) + ((hash[2] as u32) << 0); if val & mask == 0 { return i; } } return 0; } ...
use std::io::{stdout, Stdout, Write}; use std::thread; use std::time::Duration; use termion::async_stdin; use termion::event::Key; use termion::input::TermRead; use termion::raw::{IntoRawMode, RawTerminal}; use libdriver::api::{AsyncLooker, AsyncMover, AsyncSensor}; use crate::Result; pub struct RideController<T> w...
pub struct Rect { x: usize, y: usize, w: usize, h: usize } impl Rect { pub fn new(x: usize, y: usize, w: usize, h: usize) -> Self { Rect { x, y, w, h } } pub fn top(&self) -> usize { self.y + self.h - 1 } pub ...
$NetBSD: patch-.._vendor_libc-0.2.140_src_unix_bsd_netbsdlike_netbsd_mod.rs,v 1.1 2023/07/23 08:56:07 he Exp $ Replicate from main rust package to get riscv64 support. --- ../vendor/libc-0.2.140/src/unix/bsd/netbsdlike/netbsd/mod.rs.orig 2006-07-24 01:21:28.000000000 +0000 +++ ../vendor/libc-0.2.140/src/unix/bsd/netb...
use std::collections::HashSet; use std::str::FromStr; fn reallocate(banks: &mut [usize]) { let (i, mut count) = { let (i, largest) = banks.iter_mut() .enumerate() .max_by(|&(i1, &mut v1), &(i2, &mut v2)| { ...
#[doc = "Register `SR2` reader"] pub type R = crate::R<SR2_SPEC>; #[doc = "Field `REGLPS` reader - Low-power regulator started"] pub type REGLPS_R = crate::BitReader<REGLPS_A>; #[doc = "Low-power regulator started\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum REGLPS_A { #[doc = "0: Th...
use std::fs::File; use std::io::{BufRead, BufReader}; use crate::util::{lines, time}; pub fn day2() { println!("== Day 2 =="); let input = "src/day2/input.txt"; // let input = "src/day2/aoc_2022_day02_large_input.txt"; time(part_a_2, input, "A"); time(part_b_2, input, "B"); } struct Value { r...
#[doc = "Register `HWCFGR3` reader"] pub type R = crate::R<HWCFGR3_SPEC>; #[doc = "Register `HWCFGR3` writer"] pub type W = crate::W<HWCFGR3_SPEC>; #[doc = "Field `CHMAP11` reader - Input channel mapping"] pub type CHMAP11_R = crate::FieldReader; #[doc = "Field `CHMAP11` writer - Input channel mapping"] pub type CHMAP1...
#[doc = "Register `SR` reader"] pub type R = crate::R<SR_SPEC>; #[doc = "Field `PERF` reader - Preamble error flag"] pub type PERF_R = crate::BitReader; #[doc = "Field `SERF` reader - Start error flag"] pub type SERF_R = crate::BitReader; #[doc = "Field `TERF` reader - Turnaround error flag"] pub type TERF_R = crate::B...
fn main() { let names = vec!["Kannan", "Mohtashim", "Kiran"]; for name in names.iter() { match name { &"Mohtashim" => println!("There is a rustacean among us!"), _ => println!("Hello {}", name), } } println!("{:?}",names); // reusing the collection after iteration ...
// Copyright 2014 nerd-games.com. // // Licensed under the Apache License, Version 2.0. // See: http://www.apache.org/licenses/LICENSE-2.0 // This file may only be copied, modified and distributed according to those terms. #![macro_escape] pub mod logging; pub mod err;
extern crate env_logger; extern crate hyper; extern crate hubcaps; extern crate hyper_native_tls; use hyper::Client; use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; use hubcaps::{Credentials, Github}; use hubcaps::search::SearchIssuesOptions; use std::env; fn main() { env_logger::init().unw...
use crate::{ import::*, Inbox, envelope::*, error::* }; /// Reference implementation of thespis::Address<A, M>. /// It can receive all message types the actor implements thespis::Handler for. /// An actor will be dropped when all addresses to it are dropped. // pub struct Addr< A: Actor > { mb : mpsc::UnboundedSen...
/// Module to attack Transposition cipher texts. /// /// This module uses a brute force method to guess probable key used to cipher /// a text using Transposition algorithm. use crate::Result; use crate::attack::dictionaries::IdentifiedLanguage; use crate::attack::simple_attacks::{Parameters, assess_key}; use crate::a...
use std::borrow::Cow; use std::fmt::Debug; use std::sync::Arc; use command_data_derive::CommandData; use discorsd::{async_trait, BotState}; use discorsd::commands::*; use discorsd::errors::BotError; use discorsd::model::ids::*; use discorsd::model::message::TextMarkup; use crate::Bot; #[derive(Copy, Clone, Debug)] p...
use super::*; /// Postgres database functions using shell commands and db drivers use std; use std::path::Path; #[cfg(feature = "d-postgres")] use postgres::{Client, NoTls}; #[cfg(feature = "d-postgres")] use std::io::Read; #[cfg(not(feature = "d-postgres"))] use std::process::Command; #[cfg(not(feature = "d-postgre...
#[doc = "Register `DDRCTRL_INIT2` reader"] pub type R = crate::R<DDRCTRL_INIT2_SPEC>; #[doc = "Register `DDRCTRL_INIT2` writer"] pub type W = crate::W<DDRCTRL_INIT2_SPEC>; #[doc = "Field `MIN_STABLE_CLOCK_X1` reader - MIN_STABLE_CLOCK_X1"] pub type MIN_STABLE_CLOCK_X1_R = crate::FieldReader; #[doc = "Field `MIN_STABLE_...
use std::collections::BTreeMap; pub fn count_letters(str: &str) -> (usize, usize) { let mut map = BTreeMap::new(); for c in str.chars() { if !map.contains_key(&c) { map.insert(c, 1); continue; } if let Some(x) = map.get_mut(&c) { *x = *x + 1; ...
use algebra::tweedle::{ dee::{Affine as GAffine, TweedledeeParameters}, fp::Fp, }; use oracle::{ self, poseidon::PlonkSpongeConstants, sponge::{DefaultFqSponge, DefaultFrSponge, ScalarChallenge}, FqSponge, }; use commitment_dlog::commitment::{shift_scalar, PolyComm}; use plonk_protocol_dlog::p...
#![deny(warnings)] extern crate chrono; #[macro_use] extern crate error_chain; extern crate futures; extern crate hyper; extern crate hyper_tls; #[macro_use] extern crate lazy_static; extern crate mktemp; #[macro_use] extern crate mime; extern crate multipart; #[cfg(test)] #[macro_use] extern crate quickcheck; extern ...
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control Register"] pub ctrl: CTRL, _reserved0: [u8; 12usize], #[doc = "0x10 - Source Addresss"] pub srcaddr: SRCADDR, _reserved1: [u8; 12usize], #[doc = "0x20 - Length"] pub len: LEN, _reserved2: [u8; 1...
/// An enum to represent all characters in the AegeanNumbers block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum AegeanNumbers { /// \u{10100}: '๐„€' AegeanWordSeparatorLine, /// \u{10101}: '๐„' AegeanWordSeparatorDot, /// \u{10102}: '๐„‚' AegeanCheckMark, /// \u{10107}: '๐„‡' ...
// file: lib.rs // // Copyright 2015-2017 The RsGenetic Developers // // 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 ...
// Copyright 2018-2019 Parity Technologies (UK) Ltd. // // 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 applicab...
#[doc = "Reader of register DATA_MEM_DESCRIPTOR[%s]"] pub type R = crate::R<u32, super::DATA_MEM_DESCRIPTOR>; #[doc = "Writer for register DATA_MEM_DESCRIPTOR[%s]"] pub type W = crate::W<u32, super::DATA_MEM_DESCRIPTOR>; #[doc = "Register DATA_MEM_DESCRIPTOR[%s] `reset()`'s with value 0"] impl crate::ResetValue for sup...
use wal; use disk_wal::DiskWalWriter; use block_file::BlockFile; /// Permit reads of blocks /// /// Attempts to read from the block file, then /// overlay the WAL data. /// /// Writes get queued into the WAL pub struct Blocks { pub file: BlockFile, pub wal: wal::MemoryWal, disk_wal: Option<DiskWalWriter>, } impl B...
use card::Card; use types; use calculator::utility; pub fn test(cards: Vec<Card>) -> Option<types::Combination> { if cards.len() < 4 { return None; } let hash_map = utility::get_count_hash_map(&cards[..]); for (&rank_value, &count) in &hash_map { if count == 4 { return Some(types::...
#[allow(unused_imports, dead_code,unused_must_use,unused_variables)] pub mod card; #[macro_use] pub mod cardmarco; pub mod cardsmeta; pub mod board;
use std::env; use std::fs; mod chip8; fn main() { let args: Vec<String> = env::args().collect(); if args.len() != 2 { println!("usage: chip-8 <file>"); return; } let program = fs::read(&args[1]).expect("something went wrong when reading the file"); println!("{:?}", program); }
// =============================================================================== // Authors: AFRL/RQQA // Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division // // Copyright (c) 2017 Government of the United State of America, as represented by // the Secretary of th...
use std::println; use regex::Regex; static FILE: &str = include_str!("../inputs/2.txt"); lazy_static! { static ref REGEX: Regex = Regex::new("^(\\d+)-(\\d+) (\\w): (\\w+)$").unwrap(); } pub(crate) fn part1() { println!("day 2 part 1"); let num_valid = FILE .lines() .filter(|s| { ...