text
stringlengths
8
4.13M
use chrono::NaiveDate; #[derive(Clone, Debug)] pub struct TimeFrame { pub start: NaiveDate, pub end: NaiveDate, } impl TimeFrame { pub fn new(start: NaiveDate, end: NaiveDate) -> TimeFrame { TimeFrame { start, end } } }
use std::error::Error; use std::thread; use std::time::Duration; use rainbow_hat_rs::buzzer::Buzzer; const NOTES: [u32; 36] = [ 71, 71, 71, 71, 71, 71, 71, 64, 67, 71, 69, 69, 69, 69, 69, 69, 69, 62, 66, 69, 71, 71, 71, 71, 71, 71, 71, 73, 74, 77, 74, 71, 69, 66, 64, 64 ]; const TIMES: [u32; 36] = [ ...
// mod generated; // use generated::generate; use example_02_set_01::generate; fn main() { let generated_files = generate(); let size: usize = generated_files.values().map(|x| x.data.len()).sum(); println!("count: {}, size: {}", generated_files.len(), size); }
#[macro_use] extern crate failure; // #[macro_use] // extern crate lazy_static; #[macro_use] extern crate serde; #[macro_use] extern crate derive_new; #[cfg(test)] #[macro_use] extern crate serde_json; #[macro_use] mod macros; pub mod core; pub mod json; pub mod prelude; // pub mod core; // pub mod json; // pub...
pub fn and(a: bool, b: bool) -> bool { a && b } pub fn or(a: bool, b: bool) -> bool { a || b } pub fn not(a: bool) -> bool { !a } pub fn nand(a: bool, b: bool) -> bool { !(a && b) } pub fn nor(a: bool, b: bool) -> bool { !(a || b) } pub fn xor(a: bool, b: bool) -> bool { (a || b) && (!a || ...
#[doc = "Reader of register SDMMC_ID"] pub type R = crate::R<u32, super::SDMMC_ID>; #[doc = "Reader of field `IP_ID`"] pub type IP_ID_R = crate::R<u32, u32>; impl R { #[doc = "Bits 0:31 - SDMMC IP identification."] #[inline(always)] pub fn ip_id(&self) -> IP_ID_R { IP_ID_R::new((self.bits & 0xffff_f...
struct Segment { x1: u32, y1: u32, x2: u32, y2: u32, } fn main() { let input = std::fs::read_to_string("input.txt").unwrap(); let lines: Vec<&str> = input.split("\n").collect(); // parse to struct let mut segments: Vec<Segment> = Vec::new(); for line in lines { let parts: V...
use std::fmt; use std::slice; use crate::erts::term::prelude::{Boxed, Encoded, Term}; /// This struct contains the set of roots which are to be scanned during garbage collection /// /// The root set is effectively a vector of pointers to terms, i.e. pointers to the roots, /// rather than the roots directly, this is b...
// // Sysinfo // // Copyright (c) 2017 Guillaume Gomez // #[cfg(not(target_os = "windows"))] use std::fs; #[cfg(not(target_os = "windows"))] use std::path::{Path, PathBuf}; #[cfg(not(target_os = "windows"))] use std::ffi::OsStr; #[cfg(not(target_os = "windows"))] use std::os::unix::ffi::OsStrExt; #[cfg(not(target_os...
// Translated from C++ to Rust. The original C++ code can be found at // https://github.com/jk-jeon/dragonbox and carries the following license: // // Copyright 2020-2021 Junekey Jeon // // The contents of this file may be used under the terms of // the Apache License v2.0 with LLVM Exceptions. // // (See accompanyi...
use bincode::serialize; use ckb_jsonrpc_types::{JsonBytes, ScriptHashType}; use ckb_simple_account_layer::{run_with_context, CkbBlake2bHasher, Config, RunContext}; use ckb_types::{ bytes::{BufMut, Bytes, BytesMut}, core, packed, prelude::*, H160, H256, }; use ckb_vm::{ registers::{A0, A1, A7}, E...
// 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 account_common::{FidlLocalAccountId, LocalAccountId}; use failure::Error; use fidl::encoding::OutOfLine;...
extern crate chip16; extern crate sdl2; use chip16::{Cpu, Rom}; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use std::env; use std::fs::File; use std::time::Duration; fn main() { let filename = env::args().nth(1).unwrap(); let file = File::open(filename).unwrap(); let rom ...
pub mod index; pub mod binary_file_parser; #[derive(Debug)] pub enum ParseError { CantOpenFile, CantReadFile, CantParseFile, }
/// A magma. pub trait Magma: Clone { /// Performs a binary operation. fn op(&self, rhs: &Self) -> Self; /// Assigns `self.op(rhs)` to `self`. fn op_assign_right(&mut self, rhs: &Self) { *self = self.op(rhs); } /// Assigns `lhs.op(self)` to `self`. fn op_assign_left(&mut self, lhs: &Self) { *sel...
#[doc = r"Value read from the register"] pub struct R { bits: u32, } #[doc = r"Value to write to the register"] pub struct W { bits: u32, } impl super::FCRIS { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'...
#[doc = "Reader of register DMAMR"] pub type R = crate::R<u32, super::DMAMR>; #[doc = "Writer for register DMAMR"] pub type W = crate::W<u32, super::DMAMR>; #[doc = "Register DMAMR `reset()`'s with value 0"] impl crate::ResetValue for super::DMAMR { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
use crate::common::{Board, Coordinate, Player}; use crate::strategy::Strategy; pub struct NaiveStrategy { player: Player, } impl NaiveStrategy { pub fn new(player: Player) -> NaiveStrategy { NaiveStrategy { player } } } impl Strategy for NaiveStrategy { fn make_move(&mut self, board: Board) -> Option<Coo...
mod utils; use gdal::Dataset; fn main() { let ds = Dataset::open(fixture!("roads.geojson")).unwrap(); let mut layer = ds.layer(0).unwrap(); for _ in layer.features() { let _ = layer.defn(); } }
/// Test fixture, actual output, or expected result /// /// This provides conveniences for tracking the intended format (binary vs text). #[derive(Clone, Debug, PartialEq, Eq)] pub struct Data { inner: DataInner, } #[derive(Clone, Debug, PartialEq, Eq)] enum DataInner { Binary(Vec<u8>), Text(String), #...
use super::{account::has_token_account, errors::SpliffError, state::SolanaClient}; use serde::Deserialize; use solana_sdk::{ program_pack::Pack, pubkey::Pubkey, signer::{keypair::Keypair, Signer}, transaction::Transaction, }; use spl_associated_token_account::*; use spl_token::{ self, instructio...
use { anyhow::Error as AnyhowError, env_logger::{init_from_env, Env}, log::info, }; pub(crate) mod util { use std::fmt::{Debug, Display, Formatter, Result as FmtResult}; #[derive(Clone)] pub struct DebugAs<F>(pub F) where F: Fn(&mut Formatter<'_>) -> FmtResult; impl<F> Debug f...
use rand::Rng; use rand::thread_rng; use bus::Bus; use std::time::{Instant, Duration}; pub struct Cpu { bus: Bus, pc: u16, sp: u8, stack: [u16; 16], i: usize, v: [u8; 16], pub video: [[u8; 64]; 32], key: [bool; 16], delay_timer: u8, pub sound_timer: u8, delay_duration: Instant, pu...
#![deny(warnings)] use clap::{App, Arg}; use ipmpsc::{Sender, SharedRingBuffer}; use std::io::{self, BufRead}; fn main() -> Result<(), Box<dyn std::error::Error>> { let matches = App::new("ipmpsc-send") .about("ipmpsc sender example") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO...
use std::{collections::HashMap, fmt::Debug, hash::Hash, sync::Arc}; use async_trait::async_trait; use parking_lot::Mutex; use tokio::sync::{Barrier, Notify}; use super::Loader; #[derive(Debug)] enum TestLoaderResponse<V> { Answer { v: V, block: Option<Arc<Barrier>> }, Panic, } /// An easy-to-mock [`Loader`]...
mod buffer_tag; mod context_tag; mod project_tag; use crate::process::ShellCommand; use dirs::Dirs; use itertools::Itertools; use once_cell::sync::Lazy; use paths::AbsPathBuf; use rayon::prelude::*; use std::collections::HashMap; use std::hash::Hash; use std::io::{BufRead, BufReader, Error, ErrorKind, Result}; use std...
// 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::sync::Arc; use crate::Vec2; use crate::Vec2I; use crate::Vec2UI; use crate::graphics::{Backend, BufferUsage}; use super::AccelerationStructureInstance; use super::BottomLevelAccelerationStructureInfo; use super::BufferInfo; use super::LoadOp; use super::MemoryUsage; use super::RenderpassRecordingMode; use s...
//! This mod contains shared portions of the kubernetes implementations. //! //! Here are a few pointers to the resources that were used as an inspiration: //! //! - https://github.com/kubernetes/client-go/blob/master/tools/clientcmd/api/types.go //! //! A part of the official Kubernetes client library (in Go) that c...
use nom::{ bytes::complete::tag, combinator::{map, opt}, sequence::{preceded, tuple}, Err, }; use super::error::{PineError, PineErrorKind, PineResult}; use super::input::{Input, StrRange}; use super::name::{varname, varname_ws, VarName}; use super::stat_expr::all_exp; use super::stat_expr_types::{Exp, ...
#![cfg(feature = "rblas")] extern crate rblas; #[macro_use] extern crate ndarray; use rblas::Gemm; use rblas::attribute::Transpose; use ndarray::{ OwnedArray, }; use ndarray::blas::AsBlas; #[test] fn strided_matrix() { // smoke test, a matrix multiplication of uneven size let (n, m) = (45, 33); let...
pub mod prelude { pub use super::difficulty_select::DifficultySelect; pub use super::ingame::Ingame; pub use super::level_load::LevelLoad; pub use super::paused::Paused; pub use super::startup::Startup; pub use super::win::Win; } pub mod state_prelude { pub const QUIT_UI_RON_PATH: &str = "u...
use actix_web::{Error,actix::Message}; use share::schema::users; use chrono::{Utc, NaiveDateTime}; use model::response::{Msgs, SigninMsgs, UserInfoMsgs}; use model::response::MyError; #[derive(Debug,Serialize,Deserialize,PartialEq,Identifiable,Queryable)] pub struct User { pub id: i32, pub email: String, p...
fn main(){ let a = "123".to_string(); // aというラベルに123というデータを与える → 1つのアドレス → スタックの1番目 let ra= &a; // スタック2番目。所有権を借りている。aは死んでいない。 println!("{}",a); // let a1 = ra * 10; // スタック3番目。ra*10というデータを新しく作成。a1というラベルを割り当てる println!("{}",a); }
use std::fs::File; use std::io::{Read, Write}; use serde::{Deserialize, Serialize}; use toml; const CONFIG_PATH: &str = "./config.toml"; #[derive(Serialize, Deserialize)] pub struct Config { pub binding: String, pub ssl_key_path: String, pub ssl_cert_path: String, pub secret: String } impl Config { ...
use super::Collector; use collector::top_collector::TopCollector; use fastfield::FastFieldReader; use fastfield::FastValue; use schema::Field; use DocAddress; use DocId; use Result; use Score; use SegmentReader; /// The Top Field Collector keeps track of the K documents /// sorted by a fast field in the index /// /// ...
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use rabble::{self, Pid, CorrelationId, Envelope}; use msg::Msg; use super::utils::QuorumTracker; use vr::vr_msg::{self, VrMsg, RecoveryResponse, ClientOp}; use vr::VrCtx; use vr::vr_fsm::{Transition, VrState, State}; use ...
/// The 6 bytes required to notify of being a V1 binary PROXY protocol /// connection. /// /// Excerpt from the specification: /// /// > This is the format specified in version 1 of the protocol. It consists in one /// > line of US-ASCII text matching exactly the following block, sent immediately /// > and at once upon...
#[doc = r"Value read from the register"] pub struct R { bits: u32, } #[doc = r"Value to write to the register"] pub struct W { bits: u32, } impl super::STAT { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w...
use fuzzcheck::DefaultMutator; #[derive(DefaultMutator, Clone)] pub enum X { A, } #[derive(DefaultMutator, Clone)] pub enum Y { A(), } #[derive(DefaultMutator, Clone)] pub enum Z { A {}, }
use std::{ future::Future, pin::Pin, task::{self, Poll}, }; use actix_rt::ArbiterHandle; use pin_project_lite::pin_project; use crate::{ actor::{Actor, AsyncContext, Supervised}, address::{channel, Addr}, context::Context, contextimpl::ContextFut, mailbox::DEFAULT_CAPACITY, }; pin_pro...
//! Simplenote API #![feature(proc_macro)] #[macro_use] extern crate log; extern crate url; extern crate reqwest; extern crate base64; #[macro_use] extern crate serde_derive; extern crate serde_json; #[macro_use] extern crate error_chain; mod errors; mod api; mod model; pub use api::Simplenote; pub use model::Note; ...
struct Percolation { size: i64, grid: Vec<Vec<(i64, i64)>>, sizes: Vec<Vec<i64>>, } impl Percolation { fn new(size: i64) -> Percolation { let mut result = Percolation { size, grid: Vec::new(), sizes: Vec::new(), }; for x in 0..size { ...
// Copyright (c) Calibra Research // SPDX-License-Identifier: Apache-2.0 use super::*; #[test] fn test_block_signing() { let b = Record::make_block( Command { proposer: Author(1), index: 2, }, NodeTime(2), QuorumCertificateHash(47), Round(3), ...
//! Various helpers for Actix applications to use during testing. use std::sync::mpsc; use std::{net, thread}; use actix_rt::{Runtime, System}; use actix_server::{Server, StreamServiceFactory}; use futures::Future; use net2::TcpBuilder; use tokio_reactor::Handle; use tokio_tcp::TcpStream; /// The `TestServer` type. ...
use crate::Counter; use num_traits::{One, Zero}; use std::hash::Hash; use std::ops::AddAssign; impl<T, N> Extend<T> for Counter<T, N> where T: Hash + Eq, N: AddAssign + Zero + One, { /// Extend a `Counter` with an iterator of items. /// /// ```rust /// # use counter::Counter; /// # use st...
#[doc = "Reader of register CR2"] pub type R = crate::R<u32, super::CR2>; #[doc = "Writer for register CR2"] pub type W = crate::W<u32, super::CR2>; #[doc = "Register CR2 `reset()`'s with value 0"] impl crate::ResetValue for super::CR2 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
use std::io::Read; fn read<T: std::str::FromStr>() -> T { let token: String = std::io::stdin() .bytes() .map(|c| c.ok().unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().unwrap() } fn main() { let...
use super::log1p; /* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ /// Inverse hyperbolic tangent (f64) /// /// Calculates the inverse hyperbolic tangent of `x`. /// Is defined as `log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2`. #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn a...
pub fn find_primes_up_to(limit: u32) -> Vec<u32> { let mut v: Vec<_> = (2..limit).collect(); for i in 2..limit { v.retain(|&x| x <= i || x % i != 0); } v } pub fn nth(n: u32) -> u32 { let a = n as usize; let v = find_primes_up_to(105000); //to make it faster, the limit made close t th...
use wasm_bindgen::prelude::*; use serde::{Deserialize, Serialize}; mod models; use models::{Stock, StockMove, StockMoveAction, StockMoveEvent, Action, Restore, Event, StockMoveId, ItemCode, LocationCode, Quantity}; type Revision = usize; #[derive(Debug, Deserialize, Serialize)] struct Response<T> { state: ...
// Copyright (c) The cargo-guppy Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::parser::ParseError; use crate::platform::{Platform, TargetFeatures}; use crate::Target; use crate::TargetSpec; use cfg_expr::{Expression, Predicate}; use std::sync::Arc; use std::{error, fmt}; /// An error that occu...
// revisions: base nll // ignore-compare-mode-nll //[nll] compile-flags: -Z borrowck=mir #![feature(trait_upcasting)] #![allow(incomplete_features)] trait Foo<'a>: Bar<'a> {} trait Bar<'a> {} fn test_correct(x: &dyn Foo<'static>) { let _ = x as &dyn Bar<'static>; } fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'...
extern crate chrono; use self::chrono::prelude::{DateTime, Utc}; use signal::Signal; use order::{OrderKind, OrderBuilder, OcaGroup}; use order::policy::{OrderPolicy, OrderPolicyError}; pub struct SimpleOrderPolicy { order_kind: OrderKind, oca: Option<OcaGroup>, active_until: Option<DateTime<Utc>>, acti...
use std::time::Duration; use crate::{ RotatorEvent, RotatorResult, }; use crate::value::get_secret_value; pub fn test_secret(e: RotatorEvent) -> RotatorResult<()> { let timeout = Duration::from_secs(2); let _value = match get_secret_value(&e.secret_id, Some("AWSPENDING"), Some(&e.client_request_token)...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[doc(hidden)] pub struct IPhoneCallBlockedTriggerDetails(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IPhoneCallBlockedTriggerDetails {...
use amethyst::core::{ timing::Time, SystemDesc, Transform}; use amethyst::derive::SystemDesc; use amethyst::ecs::{Join, Read, ReadStorage, System, SystemData, World, WriteStorage}; use amethyst::input::{InputHandler, StringBindings}; use crate::ball::Ball; use crate::paddle::{Paddle, Side, PADDLE_WIDTH}; use crate::...
use std::io::prelude::*; use std::fs::File; #[derive(Debug, PartialEq, Clone, Copy)] enum Register { A, B, C, D } #[derive(Debug, PartialEq, Clone, Copy)] enum Op { Cpy, Inc, Dec, Jnz } #[derive(Debug, PartialEq, Clone, Copy)] enum Arg { Reg(Register), Literal(i32) } #[derive(Debug)] struct Instruc...
use crate::datastructure::DataStructure; use crate::shader::shaders::{ambient, diffuse, emittance, specular}; use crate::shader::Shader; use crate::util::ray::Ray; use crate::util::vector::Vector; #[derive(Debug)] pub struct MtlShader; impl Shader for MtlShader { fn shade<'s>(&self, ray: &Ray, datastructure: &'s ...
// 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...
/* Copyright (c) 2015, 2016 Saurav Sachidanand 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 limitation the rights to use, copy, modify, merge, publish, di...
use std::alloc::Layout; use std::borrow::Borrow; use std::env::ArgsOs; use std::mem; use std::path::Path; use std::ptr; use std::sync::OnceLock; use anyhow::anyhow; use firefly_arena::DroplessArena; use firefly_binary::{BinaryFlags, Encoding}; use firefly_rt::term::BinaryData; static ARGV: OnceLock<EnvTable> = OnceL...
pub fn sub() { println!("math.sub") }
use rand::Rng; use std::io; macro_rules! unwrap_matches { ($e:expr, $p:pat) => { match $e { $p => (), _ => panic!(""), } }; ($e:expr, $p:pat => $body:expr) => { match $e { $p => $body, _ => panic!(""), } }; } mod game_def;...
//! Encapsulates work of loading a texture from an image file //! Only ASCII PPMs (P3) are supported in this project. use std::io::BufReader; use web_sys::{WebGl2RenderingContext, WebGlTexture}; use png; pub type TextureId = usize; /// Represents an image texture #[derive(Debug)] pub struct Texture { pub tex: ...
use raytracer::image::png; use raytracer::vec3::Vec3; use raytracer::scene::{Scene, sphere::Sphere, camera::Camera}; use raytracer::ray::material::{ Lambertian , Metallic}; use std::{sync::Arc, error::Error}; use core::f64::consts::PI; fn main() -> Result<(), Box<dyn Error> > { let height: usize = 400; let w...
use gtk::*; use gio::{ApplicationFlags, ApplicationExt, ApplicationExtManual}; use std::{env, sync::{mpsc}}; use log::*; use common::{set_logging_panic_hook, init_simple_logger, start_thread_loop, convert_err}; use gui::build_ui; use message::{CompositeMessage, LogicMessage}; use logic::{LogicState}; use composite::Com...
use actix_files::Files; use actix_web::middleware::Logger; use actix_web::{get, web, App, HttpResponse, HttpServer, Result}; use actix_web_static_files; use listenfd::ListenFd; use log::error; use std::collections::HashMap; use music_box::{MusicLibrary, MusicSource}; // for bundling assents inside the binary with `a...
use rltk::{ColorPair, Point, RGB}; use specs::prelude::*; use crate::{Context, ParticleLifetime, Position, Renderable, RenderAura, RenderBackground}; pub const SHORT_LIFETIME: f32 = 300.; pub const MEDIUM_LIFETIME: f32 = 500.; pub const LONG_LIFETIME: f32 = 700.; pub fn cull_dead_particles(ecs: &mut World, context: ...
//! Async-graphql integration with Actix-web #![forbid(unsafe_code)] #![allow(clippy::upper_case_acronyms)] #![warn(missing_docs)] mod request; mod subscription; pub use request::{GraphQLBatchRequest, GraphQLRequest, GraphQLResponse}; pub use subscription::GraphQLSubscription;
pub mod model; pub mod conv2d; pub mod dense; pub mod dropout; pub mod maxpooling; pub mod relu; pub mod sigmoid; pub mod softmax;
// Copyright 2023 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 ...
// Copyright 2023 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 ...
//! Messages that are sent betweeb GUI, logic and worker threads use log::*; use glib::{Sender as GlibSender}; use std::sync::mpsc::SyncSender; use nanocv::{ImgSize, ImgBuf}; use crate::common::log_err; pub type Rgba = [u8; 4]; pub type LogicSender = SyncSender<Option<LogicMessage>>; pub type CompositorSender = SyncS...
#[macro_use] mod common; extern crate libc; use common::util::*; static UTIL_NAME: &'static str = "link"; #[test] fn test_link_existing_file() { let (at, mut ucmd) = testing(UTIL_NAME); let file = "test_link_existing_file"; let link = "test_link_existing_file_link"; at.touch(file); at.write(fil...
use crate::hitable_list::HitableList; use crate::material::Material; use crate::vec3::Vec3; use std::rc::Rc; pub struct Ray { pub origin: Vec3, pub direction: Vec3, } impl Ray { pub fn new(origin: Vec3, direction: Vec3) -> Self { Ray { origin, direction } } pub fn color(ray: &Ray, world:...
use diesel; use diesel::prelude::*; use diesel::sqlite::SqliteConnection; pub mod schema { infer_schema!("env:DATABASE_URL"); } use self::schema::users; use self::schema::users::dsl::{ users as all_users, id as user_id, username as user_name, ...
use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::state::ContractInfo; use cosmwasm_std::{to_binary, Binary, CosmosMsg, HumanAddr, StdResult, Uint128, WasmMsg}; // Instantiating an auction requires: // sell_contract: ContractInfo -- code hash and address of SNIP-20 contract of token for sa...
use std::io::Read; fn main() { let mut buf = String::new(); // 標準入力から全部bufに読み込む std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let max: u32 = iter.next().unwrap().parse().unwrap(); let start: u32 = iter.next().unwrap().parse().unwrap(); let end: ...
use lib::Config; use std::env; use std::process; mod lib; fn main() { //读取命令行参数 let args: Vec<String> = env::args().collect(); //println!("{:?}", args); //获取要搜索的字符串以及文件 let config = Config::new(&args).unwrap_or_else(|err| { //println!("Problem parsing argument:{}", err);//输出错误到标准流中 ...
use std::io; use std::io::Write; use rand; use rand::Rng; use std::collections::HashMap; pub fn solution(){ //seed random number generator for later use let mut rng = rand::thread_rng(); print!("kid list(separated by ;) > "); io::stdout().flush().unwrap(); let mut roster:String = String::new...
use crate::Result; use num::{BigInt, ToPrimitive}; // ```wl // TemplateApply[ // "cache.insert(`1`,BigInt::from(`2`));\n", // {#, Fibonacci[#]} // ]& // %/@Join[Range[0,9],PowerRange[10,100,10]] // %//StringJoin//CopyToClipboard // ``` use crate::Error::{ComplexInfinity, OverFlow}; use num::{BigUint, One}; /// TODO: ...
//! Set the visibility of the contained widget use crate::{ data::WidgetData, geometry::{BoundingBox, MeasuredSize}, input::event::InputEvent, state::WidgetState, widgets::{ utils::{ decorator::WidgetDecorator, wrapper::{Wrapper, WrapperBindable}, }, ...
#![allow(missing_docs)] #![deny(warnings)] extern crate libc; use std::mem; use self::libc::{ c_char, int32_t, uint8_t, uint16_t, uint32_t, uint64_t }; /* the following events that user-space can register for */ //#define FAN_ACCESS 0x00000001 /* File was accessed */ ///File...
use std::io; fn main() { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); let n: i64 = buf.trim().parse().unwrap(); let mut count: i64 = 0; for i in 1..n + 1 { if i % 3 != 0 && i % 5 != 0 { count += i; } } println!("{}", count); }
use std::time::Duration; use async_std::io::{timeout as tout, Error}; use async_std::net::TcpStream; pub async fn check_network(addrs: &str, timeout: Duration) -> Result<bool, Error> { match tout(timeout, TcpStream::connect(addrs)).await { Ok(_) => Ok(true), Err(e) => Err(e), } }
// 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::{client, known_ess_store::KnownEssStore}; use fidl::{self, endpoints::create_proxy}; use fidl_fuchsia_wlan_common as fidl_common; use fidl_fuch...
use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { TargetOptions { env: "gnu".into(), ..super::linux_base::opts() } }
#![feature(test)] extern crate test; extern crate snow; use snow::*; use snow::params::*; use snow::types::*; use snow::wrappers::crypto_wrapper::Dh25519; use snow::wrappers::rand_wrapper::RandomOs; use test::Bencher; const MSG_SIZE: usize = 4096; pub fn copy_memory(data: &[u8], out: &mut [u8]) -> usize { for c...
// 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 ...
#[derive(Debug)] enum List { Cons(Rc<RefCell<i32>>, Rc<List>), Nil, } use crate::List::{Cons, Nil}; use std::rc::Rc; use std::cell::RefCell; /* A common way to use RefCell<T> is in combination with Rc<T>. Recall that Rc<T> lets you have multiple owners of some data, but it only gives immutable access to tha...
pub mod attribute; pub mod instruction; pub mod read; pub mod class; pub mod field; pub mod method; pub mod constant; pub use instruction::Instruction; use crate::class_file::unvalidated::attribute::Attribute; pub use crate::class_file::unvalidated::attribute::AttributeInfo; pub use crate::class_file::unvalidated::a...
use crate::schema::order_detail; use chrono::NaiveDateTime; use uuid::Uuid; #[derive( Clone, Debug, Serialize, Associations, Deserialize, PartialEq, Identifiable, Queryable, Insertable, )] #[table_name = "order_detail"] pub struct OrderDetail { pub id: i32, pub order_id: i...
extern crate rand; use std::marker::PhantomData; pub struct Cubby<C,V,T> { ents: Box<[C]>, dead: V, _pd: PhantomData<T>, } impl<C:BackendC<T>,V:BackendV,T:Send+Sync> Cubby<C,V,T> { pub fn new<F: Fn(Ent<T>) -> C, F2: Fn(Vec<usize>) -> V> (f:F,f2:F2, s:usize) -> Cubby<C,V,T> { let mut ...
#![crate_name = "locale"] #![crate_type = "rlib"] #![crate_type = "dylib"] //! Localisation is hard. //! //! Getting your program to work well in multiple languages is a world fraught with edge-cases, //! minor grammatical errors, and most importantly, subtle things that don't map over well that you //! have absolutel...
extern crate hyper; use futures::sync::mpsc::{unbounded, UnboundedReceiver}; use std::thread; use args::Config; use run_info::RunInfo; use misc::split_number; use tokio_core::reactor::Core; use chrono::{Local}; use hyper::{Client, Uri}; use std::str::FromStr; use hyper::client::HttpConnector; use std::net::lookup_hos...
pub struct User { pub id: String, pub name: String, pub friend_ids: Vec<String>, pub workout_plan_ids: Vec<String>, }
use std::fmt::Display; use std::iter::FromIterator; use itertools::{Itertools, zip}; use board::group_access::GroupAccess; use board::stones::grouprc::GoGroupRc; use display::display::GoDisplay; use display::goshow::GoShow; use display::range::Range2; use rust_tools::screen::dimension::Dimension; use rust_tools::scre...
//! Parsers for the different QVM and related formats. use super::{Instruction, QVM, VM_MAGIC}; use opcodes::Opcode; use super::errors::*; use nom; use nom::{le_u32, le_u8}; type Input = u8; type InputSlice<'a> = &'a [Input]; /// Creates a named parser for an instruction that only consists of an opcode macro_rules! ...
use std::cmp::{Eq, PartialEq}; use std::ops::{Add, Div, Mul, Neg, Sub}; use crate::geometry::dq::DualQuaternion; // Equality: DualQuaternion impl PartialEq<DualQuaternion> for DualQuaternion { fn eq(&self, other: &DualQuaternion) -> bool { let q1 = self; let q2 = other; q1.p == q2.p && q1.d == q2.d } ...