text
stringlengths
8
4.13M
use std::rc::Rc; use std::collections::HashMap; use {Value, Procedure, AresResult, AresError, ParamBinding, LoadedContext, State, Environment}; use super::util::expect_arity; use intern::Symbol; pub fn equals(args: &[Value]) -> AresResult<Value> { try!(expect_arity(args, |l| l >= 2, "at least 2")); let first =...
use std::path::PathBuf; use clap::ArgMatches; use cli; pub fn load_config() -> UpdaterConfig { let cli_app = cli::create_cli_app(); let matches = cli_app.get_matches(); UpdaterConfig { target_directory: get_string_value(&matches, "target-directory").map(|d| PathBuf::from(d)), exclude_asn: ...
#[doc = "Register `ETH_MTLRxQ0MPOCR` reader"] pub type R = crate::R<ETH_MTLRX_Q0MPOCR_SPEC>; #[doc = "Field `OVFPKTCNT` reader - OVFPKTCNT"] pub type OVFPKTCNT_R = crate::FieldReader<u16>; #[doc = "Field `OVFCNTOVF` reader - OVFCNTOVF"] pub type OVFCNTOVF_R = crate::BitReader; #[doc = "Field `MISPKTCNT` reader - MISPKT...
use super::*; #[cfg(test)] mod tests { use super::*; #[test] fn test_const() { println!("1"); let mut graph = Graph::new(); println!("2"); let a = ops::Const::<f32>::new(Box::new(Tensor::<f32>::new(&vec![1,2]))).finish(); println!("3"); let options = SessionOptions::new(); println!("4...
//! Providing auxiliary information for signals. use std::io::Error; use std::mem; use std::ptr; use libc::{c_int, EINVAL}; #[cfg(not(windows))] use libc::{sigset_t, SIG_UNBLOCK}; use crate::consts::signal::*; use crate::low_level; #[derive(Clone, Copy, Debug)] enum DefaultKind { Ignore, #[cfg(not(windows))...
// ====================================== // nanomsg.rs : nanomsg bindings for rust // // This aims to be a rust version of the // full public API of nanomsg. But parts // are probably still missing, since the // safe API only does nn_send and nn_recv // currently. // ====================================== #![crate_na...
use action::Action; use bluetooth::Bluetooth; use core::marker::Unsize; use debug::UnwrapLog; use hidreport::HidReport; use keycodes::KeyCode; use keymatrix::KeyState; use layout::LAYERS; use layout::LAYER_BT; use led::Led; use stm32l151::SCB; use stm32l151::SYST; use usb::Usb; pub struct Keyboard { layers: Layers...
// // sprocketnes/rom.rs // // Author: Patrick Walton // use std::io::File; use std::vec::Vec; pub struct Rom { pub header: INesHeader, pub prg: Vec<u8>, // PRG-ROM pub chr: Vec<u8>, // CHR-ROM } impl Rom { fn from_file(file: &mut File) -> Rom { let mut buffer = [ 0, ..16 ]; ...
pub mod docker; mod ssl_tcp_docker; mod tcp_docker; mod unix_docker; pub mod util; pub mod container; pub mod image; pub mod images; pub mod containers; pub mod network; pub mod networks; pub use container::Container; pub use image::Image; pub use images::Images; pub use network::Network; pub use docker::{DockerApi, ...
use crate::nes::{Nes, NesIo}; use bitflags::bitflags; use std::cell::Cell; use std::fmt; use std::ops::Generator; use std::u8; #[derive(Debug, Clone)] pub struct Cpu { pub pc: Cell<u16>, pub a: Cell<u8>, pub x: Cell<u8>, pub y: Cell<u8>, pub s: Cell<u8>, pub p: Cell<CpuFlags>, pub nmi: Cell...
use libc; use libnice_sys::{ nice_address_set_from_string, nice_address_set_port, nice_candidate_free, nice_candidate_new, NiceCandidate, NiceCandidateTransport_NICE_CANDIDATE_TRANSPORT_UDP, NiceCandidateType_NICE_CANDIDATE_TYPE_HOST, NiceCandidateType_NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE, }; use std::{...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - MCU Device ID Code Register"] pub idcode: IDCODE, #[doc = "0x04 - Debug MCU Configuration Register"] pub cr: CR, #[doc = "0x08 - APB Low Freeze Register 1"] pub apb1l_fz: APB1L_FZ, #[doc = "0x0c - APB Low Freeze...
use sdl2::keyboard::Scancode; use specs::prelude::*; use crate::ecs::components::*; use crate::ecs::resources::*; use crate::ecs::weapon::*; pub struct HealthSystem; impl<'a> System<'a> for HealthSystem { type SystemData = (Entities<'a>, WriteStorage<'a, Health>, Read<'a, LazyUpdate>); fn run(&mut self, dat...
extern crate advent_of_code_2017_day_4;
// SPDX-FileCopyrightText: 2020-2021 HH Partners // // SPDX-License-Identifier: MIT use serde::{Deserialize, Serialize}; use crate::Algorithm; use super::{Checksum, FileType, SPDXExpression}; /// ## File Information /// /// SPDX's [File Information](https://spdx.github.io/spdx-spec/4-file-information/) #[derive(Deb...
//! Variable-width 64-bit little endian integers use byteorder::{ByteOrder, LittleEndian}; /// Encode a 64-bit unsigned integer in zsuint64 form pub fn encode(value: u64, out: &mut [u8]) -> usize { let mut length = 1; let mut result = (value << 1) | 1; let mut max = 1 << 7; while value >= max { ...
use graphics::tileset::TilesetDesc; use tilemap::MapBuilder; pub struct Tilesets { pub tileset_descs: Vec<TilesetDesc>, } impl Tilesets { pub fn empty() -> Self { Tilesets { tileset_descs: vec![], } } pub fn build(builder: &mut MapBuilder) -> Self { // Reborrow. `&...
mod errors; mod hash_map; mod taking_input; mod traits; mod triangle; mod vectors; use std::io::Write; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use crate::traits::GetInfo; use anyhow::{Context, Result}; fn main() -> Result<()> { let test_type: String = get_test_type(); if t...
pub mod scanner; pub mod literal; use literal::Literal; #[derive(Debug, Clone)] pub struct Token { pub ttype: TokenType, pub lexeme: String, pub line: usize, pub start: usize } impl Token { pub fn new(ttype: TokenType, lexeme: String, line: usize, start: usize) -> Self { Self { ...
use serde::Serialize; use serde_json::value::{to_value, Value as Json}; use serde_json::Map; use crate::op::Op; use crate::error::{Error, Result}; use crate::arg::Arg; /// The Rule type, contains an `Expr`. #[derive(Clone, Debug, PartialEq)] pub struct Rule { expr: Expr, } impl Rule { /// Constructs a new `R...
mod sql_test; use apllodb_server::{test_support::test_setup, RecordIndex, SchemaIndex, SqlState}; use sql_test::{SqlTest, Step, StepRes, Steps}; #[ctor::ctor] fn setup() { test_setup(); } #[async_std::test] async fn test_select_with_various_field_spec() { #[derive(Clone)] struct TestDatum { sql: ...
use particle::collide::collide::Collider; use sack::{SackType, SackBacker, Sack}; /// An important special case of a Collider is where a sack is absorbed into another one without /// changing the type signature of the original pub trait Absorber<'a, C1: 'a, C2: 'a, D1: 'a, D2: 'a, B1: 'a, B2: 'a, T1: 'a> : Collide...
pub mod parser; pub mod info; pub fn run(tickers: Vec<String>) { let parser = parser::Parser{tickers: tickers}; println!("{:#?}", parser.parse()); }
mod repl; pub use repl::*;
use crate::io::request::*; use crate::io::Core; use crate::{ BuildDeferredQueryIndexOptions, CouchbaseError, CouchbaseResult, CreatePrimaryQueryIndexOptions, CreateQueryIndexOptions, DropPrimaryQueryIndexOptions, DropQueryIndexOptions, ErrorContext, GetAllQueryIndexOptions, QueryOptions, WatchIndexesQue...
use serde_derive::Deserialize; use serde_json::json; use lambda_http::{lambda, Body, IntoResponse, Request, RequestExt, Response}; use lambda_runtime::{error::HandlerError, Context}; use rand::distributions::StandardNormal; use rand::{thread_rng, Rng}; use rayon::prelude::*; use std::collections::HashMap; use std::err...
mod selection; use std::{cell::Cell, rc::Rc}; pub use self::selection::Selection; use super::{Theme, WidgetCommon, Widgetlike}; pub struct UISource { selection: Cell<Selection>, layout_token: Cell<u64>, theme: Cell<Theme>, } #[derive(Clone)] pub struct UI { state: Rc<UISource>, context: UICont...
use chrono::{Datelike, Timelike}; pub struct Macro { pub name: String, pub value: String } impl Macro { pub fn predefine_all(file: &str) { Self::add("__STDC__", "1"); Self::add("__STDC_VERSION__", "199901"); Self::add("__RUST__", ""); Self::add("__qas_minor__", "0"); ...
extern crate hyper; extern crate hyper_tls; extern crate reqwest; extern crate serde; extern crate serde_json; use hyper::rt::{self, run, Future, Stream}; use hyper::Client; use hyper::{Body, Chunk, Error, Method, Request, Response, Server, StatusCode}; use serde_json::Value; use chrono::prelude::*; use hyper::client...
use std::ffi::{CStr, CString}; use std::os::raw::c_char; use serde_json::{Value, json}; pub use stardog_function::*; #[no_mangle] pub extern fn evaluate(subject: *mut c_char) -> *mut c_char { let subject = unsafe { CStr::from_ptr(subject).to_str().unwrap() }; let values: Value = serde_json::from_str(subject...
// Copyright 2015-2020 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any ...
fn solution(num: i32) -> i32 { let mut sum: i32 = 0; for i in 0..num { if i % 5 == 0 || i % 3 == 0 { sum += i } } return sum; }
extern crate rand; use std::io::{self, Write}; use std::time::{Instant, Duration}; use std::process::Command; use rand::Rng; fn main() { let stdout = io::stdout(); let mut stdout = stdout.lock(); let mut buf = [0; 128]; let mut rng = rand::thread_rng(); let start = Instant::now(); loop { ...
use crate::models::Info; use crate::{errors::ApiError}; use actix_web::{delete, get, post, web, HttpResponse}; #[post("/api/logs")] async fn post_logs(info: web::Json<Info>) -> Result<HttpResponse, ApiError> { let result = Info::save(info.into_inner())?; return Ok(HttpResponse::Ok().json(result)); } #[get("/a...
mod daemon; fn main() { daemon::daemon::<fal_backend_apfs::Filesystem<std::fs::File>>(":apfs".as_ref()) }
#[doc = "Reader of register ARB_CFG"] pub type R = crate::R<u32, super::ARB_CFG>; #[doc = "Writer for register ARB_CFG"] pub type W = crate::W<u32, super::ARB_CFG>; #[doc = "Register ARB_CFG `reset()`'s with value 0"] impl crate::ResetValue for super::ARB_CFG { type Type = u32; #[inline(always)] fn reset_va...
#[doc = "Register `SMPR2` reader"] pub type R = crate::R<SMPR2_SPEC>; #[doc = "Register `SMPR2` writer"] pub type W = crate::W<SMPR2_SPEC>; #[doc = "Field `SMP10` reader - SMP10"] pub type SMP10_R = crate::FieldReader<SMP10_A>; #[doc = "SMP10\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[repr(u8...
//! This is not an example; this is a linker overflow detection test //! which should fail to link due to .data overflowing FLASH. #![deny(warnings)] #![no_main] #![no_std] extern crate cortex_m_rt as rt; extern crate panic_halt; use core::ptr; use rt::entry; // This large static array uses most of .rodata static ...
use crate::chunk::chunk_payload_data::ChunkPayloadData; use crate::chunk::chunk_selective_ack::GapAckBlock; use crate::util::*; use std::collections::HashMap; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; #[derive(Default, Debug)] pub(crate) struct PayloadQueue { pub(crate) length: Arc<Atomi...
// unihernandez22 // https://atcoder.jp/contests/abc157/tasks/abc157_c // implementation use std::io::stdin; use std::collections::HashMap; fn digits(mut n: i64) -> Vec<i64> { let mut ans = Vec::<i64>::new(); while n > 0 { ans.push(n % 10); n /= 10; } ans.reverse(); return ans; } ...
use structopt::StructOpt; // 1 - Definindo uma estrutura da linha de comando #[derive(StructOpt)] struct Cli{ padrao: String, #[structopt(parse(from_os_str))] arquivo: std::path::PathBuf, } //Por padrão o o software apenas lê o arquivo texto. Porém, pode ter a opção –l //que só exibe a linha e ou –w que só exib...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - EXTI rising trigger selection register"] pub rtsr1: RTSR1, #[doc = "0x04 - EXTI falling trigger selection register"] pub ftsr1: FTSR1, #[doc = "0x08 - EXTI software interrupt event register"] pub swier1: SWIER1, ...
use thiserror::Error; #[derive(Debug, Error)] pub enum NishiokaNagatsuError { #[error("The width or height is not 256 [pixels]; Width = {w}, Height = {h}")] SizeIsNot256x256Pixels { w: u32, h: u32 }, #[error("The color type is not RGB8 or RGBA8. Color = {0:?}")] ColorTypeIsNotRgb8OrRgba8(image::ColorType) }
struct CancelParams { id: i32; }
use pyo3::prelude::*; #[pyfunction] fn get_22() -> usize { 22 } #[pymodule] fn rust(_py: Python, m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(get_22))?; Ok(()) }
use redis::Client; use serenity::{client::bridge::gateway::ShardManager, prelude::Mutex, prelude::TypeMapKey}; use sqlx::PgPool; use std::sync::Arc; use tts::backend::gcp::GcpToken; pub struct ShardManagerContainer; impl TypeMapKey for ShardManagerContainer { type Value = Arc<Mutex<ShardManager>>; } pub struct D...
// Inside `src/models.rs` // This `models` file will also be imported into our `lib` // We JUST made the schema file... // Lets take advantage of it by bringing it into scope here // get code from diesel tutorial and make CRUD example for this #![feature(type_ascription)] extern crate chrono; use schema::{posts, u...
extern crate bitcoin; extern crate byteorder; extern crate chrono; extern crate failure; extern crate hex; #[macro_use] extern crate lazy_static; extern crate ripemd160; extern crate secp256k1; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate sha2; #[macro_use] pub mod ...
use libc; use std::mem::MaybeUninit; use chrono::Duration; use friendly::{bytes, duration}; use log::*; fn timeval_duration(tv: &libc::timeval) -> Duration { let ds = Duration::seconds(tv.tv_sec); let dus = Duration::microseconds(tv.tv_usec.into()); ds + dus } /// Print closing process statistics. pub fn...
extern "C" { fn the_worst_wrapper(callback: Option<extern "C" fn() -> ()>) -> i32; fn callback_error(error: i32); } thread_local! { pub static ERROR_CONTEXT: std::cell::Cell<&'static str> = std::cell::Cell::new("no error"); } extern "C" fn my_callback() { println!("[my_callback]: enter"); ...
pub mod compiler; pub mod parser; pub mod checked_expr; use super::token::{Token, literal::Literal}; #[derive(Clone, Debug)] pub enum Expr { Binary(Box<Expr>, Token, Box<Expr>), MsgEmission(Option<Box<Expr>>, Token, Option<Box<Expr>>), BinaryOpt(Box<Expr>, Token, Option<Box<Expr>>), Asm(Box<Expr>, Box...
mod tile; pub fn solve_1() { let grid = tile::grid(include_str!("input.txt")); let step = tile::Point2D::new(3, 1); let tree_count = tile::traverse(grid, step) .iter() .filter(|&&t| t == tile::Tile::Tree) .count(); println!( "Encountered {} trees starting from the top left corner.", tree_count ); } pu...
#![cfg(test)] use super::*; use crate::physics::single_chain::test::Parameters; mod base { use super::*; use rand::Rng; #[test] fn init() { let parameters = Parameters::default(); let _ = FJC::init(parameters.number_of_links_minimum, parameters.link_length_reference, param...
#[macro_use] extern crate nom; use nom::IResult; use nom::util::{generate_colors,prepare_errors,print_codes,print_offsets}; use std::collections::HashMap; fn main() { named!(err_test, alt!( tag!("abcd") | error!(12, preceded!(tag!("efgh"), error!(42, chain!( tag!("ijk") ...
#![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct AutoStorageBaseProperties { #[serde(rename = "storageAccountId")] pub storage_account_id: String, } #[deriv...
pub struct Post { state: Option<Box<dyn State>>, content: String, pub approves_count: u32, } impl Post { pub fn new() -> Post { Post { state: Some(Box::new(Draft {})), content: String::new(), approves_count: 0, } } pub fn add_text(&mut self,...
use crate::execution::chunk::{Chunk, Opcode}; use crate::image_parsing::ast::{Program, Stmt, Expr, Op}; use std::collections::HashMap; pub fn compile(program:&Program) -> Result<Chunk, String> { let mut res = Chunk::new(); let variable_map = assign_variables(program)?; let mut compiler = Compiler{variable...
use amethyst::{core::{Axis2, transform::Transform}, ecs::World, renderer::Camera, utils::ortho_camera::{CameraNormalizeMode, CameraOrtho, CameraOrthoWorldCoordinates}}; pub fn initialize_camera(world: &mut World, width: f32, height: f32) { let mut transform = Transform::default(); transform.set_translation_xyz...
//! Save bad network\'s ass. pub mod models; pub mod parser; pub mod schemas; mod sql; use self::models::*; use self::schemas::{problems::dsl::*, tags::dsl::*}; use self::sql::*; use crate::helper::test_cases_path; use crate::{config::Config, err::Error, plugins::LeetCode}; use anyhow::anyhow; use colored::Colorize; us...
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ pub mod family; use ::syscalls::SyscallArgs; use ::syscalls::Sysno; // Re-export flags that used b...
extern crate sdl2; use super::super::world::player; use super::font_renderer; use sdl2::rect; use sdl2::render; use sdl2::video; pub struct PlayerRenderer { texture: (sdl2::render::Texture, u32, u32), } impl PlayerRenderer { pub fn new(renderer: &font_renderer::FontRenderer) -> Result<PlayerRenderer, String>...
impl Solution { pub fn equal_substring(s: String, t: String, max_cost: i32) -> i32 { let (mut start,mut end,mut cost) = (0,0,0); let mut res = 0; let (s,t) = (s.into_bytes(),t.into_bytes()); //维护一个窗口,窗口的尾部是一直往前走的,窗口内的cost只要大于maxcost就往前移动头部 //直到窗口内部cost是小于等于maxcost的 wh...
use autocfg::AutoCfg; fn main() { match AutoCfg::new() { Ok(ac) => { // The #[track_caller] attribute was stabilized in rustc 1.46.0. if ac.probe_rustc_version(1, 46) { autocfg::emit("tokio_track_caller") } } Err(e) => { // If...
//! The way terminal input is handled. pub mod actions; pub mod config; pub mod handler; pub mod keybinds;
use std::collections::HashMap; // Deterministic Finite Automata (DFA) // also known as a Finite-state Machine pub type StateMachine = State; #[derive(Debug)] pub struct State { transitions: HashMap<char, State>, terminal: bool, } impl StateMachine { pub fn new() -> Self { State { tran...
mod compile; mod targets; pub mod tempfile; mod util; use self::compile::SharedLibraries; use crate::config::{AndroidConfig, AndroidTargetConfig}; use anyhow::format_err; use cargo::core::{Target, TargetKind, Workspace}; use cargo::util::process_builder::process; use cargo::util::CargoResult; use clap::ArgMatches; use...
use actix_files::Files; use actix_web::{ error::InternalError, http::StatusCode, middleware, web, App, HttpRequest, HttpResponse, HttpServer, }; use sailfish::TemplateOnce; #[derive(sailfish_macros::TemplateOnce)] #[template(path = "index.stpl")] struct Index; async fn index(_: HttpRequest) -> actix_web::Resu...
use core::marker::PhantomData; use crate::cogs::{ ActiveLineageSampler, BackedUp, Backup, CoalescenceSampler, DispersalSampler, EmigrationExit, EventSampler, Habitat, ImmigrationEntry, LineageReference, LineageStore, RngCore, SpeciationProbability, TurnoverRate, }; use super::Simulation; #[contract_trait...
pub mod ast; pub mod back; mod front; mod loc; use back::env::SmartEnv; use loc::Loc; pub fn parse_eval_print(env: SmartEnv, filename: &str, input: &str) -> String { let parse_result = front::parse(filename, input); match parse_result { Ok(nodes) => { let eval_result = back::eval(env, nod...
use query_builder::{CombinableQuery, IntersectQuery}; pub trait IntersectDsl<U: CombinableQuery<SqlType = Self::SqlType>>: CombinableQuery { type Output: CombinableQuery<SqlType = Self::SqlType>; fn intersect(self, query: U) -> Self::Output; } impl<T, U> IntersectDsl<U> for T where T: CombinableQuery, ...
use crate::types::{ActivationFrame, Closure, Escape, Primitive, Scm, Symbol}; use std::any::{Any, TypeId}; use std::fmt::{Debug, Display}; pub trait UserValue: Debug + Display + 'static { fn type_id(&self) -> TypeId; } impl<T: Debug + Display + 'static> UserValue for T { fn type_id(&self) -> TypeId { ...
use ast::{lit_from_token, EnumMacro}; use proc_macro2::TokenStream; use syn::*; pub fn forward_impl(input: TokenStream) -> Result<TokenStream> { dump!(input); Ok(quote! { #input }) } pub fn make_enum(input: TokenStream) -> Result<TokenStream> { let input = syn::parse2::<EnumMacro>(input)?; split!(inp...
#[doc = "Reader of register SOF1"] pub type R = crate::R<u32, super::SOF1>; #[doc = "Reader of field `FRAME_NUMBER_MSB`"] pub type FRAME_NUMBER_MSB_R = crate::R<u8, u8>; impl R { #[doc = "Bits 0:2 - It has the upper 3 bits \\[10:8\\] of the SOF frame number."] #[inline(always)] pub fn frame_number_msb(&self...
/* chapter 4 syntax and semantics */ fn main() { let dog = "hachiko"; let hachi = &dog[0..5]; println!("{}", hachi); } // output should be: /* */
/// An enum to represent all characters in the NewTaiLue block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum NewTaiLue { /// \u{1980}: 'ᦀ' LetterHighQa, /// \u{1981}: 'ᦁ' LetterLowQa, /// \u{1982}: 'ᦂ' LetterHighKa, /// \u{1983}: 'ᦃ' LetterHighXa, /// \u{1984}: 'ᦄ' ...
use aoc::read_data; use std::error::Error; use std::num::ParseIntError; use std::str::FromStr; #[derive(Debug)] struct Password { min: usize, max: usize, c: char, pass: String, } impl Password { fn is_valid_1(&self) -> bool { let matches = self.pass.matches(self.c).count(); self.mi...
#[doc = "Reader of register CLK_FLL_CONFIG"] pub type R = crate::R<u32, super::CLK_FLL_CONFIG>; #[doc = "Writer for register CLK_FLL_CONFIG"] pub type W = crate::W<u32, super::CLK_FLL_CONFIG>; #[doc = "Register CLK_FLL_CONFIG `reset()`'s with value 0x0100_0000"] impl crate::ResetValue for super::CLK_FLL_CONFIG { ty...
/// Multiboot Parsing /// /// Multiboot describes a protocol for transferring control from a bootloader to /// an operating system. Denuos uses GRUB2 to load. GRUB is responsible for /// reading our entire kernel image from disk, loading it into memory, and /// retrieving critical information from the BIOS before trans...
//! Color profiles. use crate::gamma::ToneCurve; use crate::mlu::MLU; use crate::named::NamedColorList; use crate::pcs::MAX_ENCODABLE_XYZ; use crate::pipe::{Pipeline, Stage}; use crate::white_point::{adaptation_matrix, D50}; use crate::{CIExyYTriple, ColorSpace, ICCTag, Intent, ProfileClass, CIEXYZ}; use cgmath::{Matr...
$NetBSD: patch-third__party_rust_authenticator_src_netbsd_transaction.rs,v 1.1 2023/02/05 08:32:24 he Exp $ --- third_party/rust/authenticator/src/netbsd/transaction.rs.orig 2020-09-02 20:55:31.087295047 +0000 +++ third_party/rust/authenticator/src/netbsd/transaction.rs @@ -0,0 +1,50 @@ +/* This Source Code Form is su...
/*! Definition of the program's main error type. */ use std::borrow::Cow; use std::error::Error; use std::fmt; use std::io; use std::result::Result; /// Shorthand for the program's common result type. pub type MainResult<T> = Result<T, MainError>; /// An error in the program. #[derive(Debug)] pub enum MainError { ...
mod handler; mod player; mod server; mod voice; extern crate regex; use regex::Regex; extern crate serenity; use serenity::client::Client; use serenity::prelude::Mutex; use std::collections::HashMap; use std::env; use std::net::UdpSocket; use std::str; use std::sync::Arc; use std::thread; use handler::Handler; use ...
mod accessibility; pub struct CSR { }
use std::sync::Arc; use vulkano::device::{Device, DeviceExtensions, Queue, QueuesIter}; use vulkano::image::SwapchainImage; use vulkano::instance::{self, Features, Instance, InstanceExtensions, PhysicalDevice, QueueFamily, debug::DebugCallback}; use vulkano::swapchain::{PresentMode, Surface, Sur...
use crate::image::ImageState; use crate::job::build::BuildContainerCtx; use crate::util::create_tar_archive; use crate::Result; use std::path::Path; use std::path::PathBuf; use tracing::{debug, info, info_span, trace, Instrument}; impl<'job> BuildContainerCtx<'job> { /// Creates a final DEB packages and saves it ...
use std::cmp::{Eq, PartialEq}; use std::fmt::Display; use std::path::PathBuf; use std::string::ToString; use super::ast::AstNode; #[derive(Debug, Clone)] pub struct FilePos { pub line: usize, pub column: usize, pub source: PathBuf, } impl FilePos { pub fn new(line: usize, column: usize, source: PathB...
#[doc = "Register `IPCC_HWCFGR` reader"] pub type R = crate::R<IPCC_HWCFGR_SPEC>; #[doc = "Field `CHANNELS` reader - CHANNELS"] pub type CHANNELS_R = crate::FieldReader; impl R { #[doc = "Bits 0:7 - CHANNELS"] #[inline(always)] pub fn channels(&self) -> CHANNELS_R { CHANNELS_R::new((self.bits & 0xff...
use std::option::Option::Some; use crate::leet_code::common::chain_table::ListNode; /// 从尾到头打印链表 /// /// 输入:head = [1,3,2] /// 输出:[2,3,1] pub fn main() { let test_node = ListNode::produce_chain(vec![1, 3, 2]); let result = Solution::reverse_print(test_node); println!("{:?}", result); } struct Solution; ...
mod client; mod inner; mod reader; mod writer; mod error; pub use self::client::Client;
mod timing { use super::super::{try_advance_departure_time, try_recede_departure_time}; use crate::construction::constraints::*; use crate::construction::heuristics::*; use crate::helpers::construction::constraints::create_constraint_pipeline_with_transport; use crate::helpers::models::domain::{crea...
extern crate bufstream; use std::collections::HashMap; use std::net::TcpStream; use self::bufstream::BufStream; use commands; use error::{BeanstalkdError, BeanstalkdResult}; use parse; use request::Request; use response::{Response, Status}; macro_rules! try { ($e:expr) => (match $e { Ok(e) => e, Err(_) => return...
use SafeWrapper; use ir::{User, Instruction, Value}; use sys; /// An instruction which can insert an element into a vector. pub struct InsertElementInst<'ctx>(Instruction<'ctx>); impl<'ctx> InsertElementInst<'ctx> { /// Creates a new insert element instruction. pub fn new(vector: &Value, new_el...
fn main() { println!("Hello, world!"); } #[test] fn offset_method(){ let s: &str = "Rust"; let ptr: *const u8 = s.as_ptr(); unsafe { println!("{:?}", *ptr.offset(1) as char); println!("{:?}", *ptr.offset(3) as char); println!("{:?}", *ptr.offset(25) as char); } } #[test] fn ...
mod ghash; mod hmac; mod poly1305; mod polyval; pub use self::ghash::GHash; pub use self::hmac::*; pub use self::poly1305::Poly1305; pub use self::polyval::Polyval; #[cfg(test)] #[bench] fn bench_poly1305(b: &mut test::Bencher) { let key = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a...
// https://www.codewars.com/kata/56445c4755d0e45b8c00010a fn fortune(f0: i32, p: f64, c0: i32, n: i32, i: f64) -> bool { let mut money: i64 = f0.into(); let mut cost: i64 = c0.into(); for _ in 0..n { money += (p / 100.0 * money as f64) as i64 - cost; if money <= 0 { return false; } ...
//! //! Data Constistency Guarantee Methods. //! //! These are designed to provide the same interface than the client, wrapping around it and providing the same //! interface `ClientTrait`. //! mod file; use std::fmt::Debug; pub use file::FileBacklog; use crate::Record; use crate::InfluxResult; /// API definition ...
use iron::prelude::*; use iron::status; use iron_sessionstorage::SessionRequestExt; use router::Router; use mount::Mount; use params; use params::FromValue; use std::str::FromStr; use auth::SessionData; use middleware::DatabaseExt; use models::*; use repo; macro_rules! require_login { ($req:ident) => { ma...
use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("devinez le nombre!"); let nombre_secret = rand::thread_rng().gen_range(1, 101); loop { println!("Veuillez entrer un nombre"); let mut supposition = String::new(); io::stdin().read_line(&mut supposition) ...
fn main() { let x = 9; if x { println!("bigger: {}", x); } else { println!("less: {}", x); } }
fn main() { println!("Hello, world!"); } // this function can be accessed from Javascript (no_mangle) #[no_mangle] pub extern "C" fn add_one(x: i32) -> i32 { x + 1 }