text
stringlengths
8
4.13M
use crate::{error::Error, powerline::Segment}; mod cmd; mod cwd; mod git; mod host; mod readonly; mod user; mod newline; mod k8scontext; mod awsvault; pub use cmd::{Cmd, CmdScheme}; pub use cwd::{Cwd, CwdScheme}; pub use git::{Git, GitScheme}; pub use host::{Host, HostScheme}; pub use readonly::{ReadOnly, ReadOnlySch...
//! Data Transformation Contract. use crate::raw_transmute::inline_unchecked_transmute; use core::hash::Hash; use core::marker::PhantomData; use core::fmt::Debug; use core::ops::DerefMut; use core::ops::Deref; /// A contract for converting or reading data of related types. /// Creating such a contract is not safe b...
use crate::error::StoreError; use crate::event_handler::OneshotData; use crate::store; use crate::store::StatsStore; use indicatif::{ProgressBar, ProgressStyle}; use rusqlite::ErrorCode; use serenity::model::id::GuildId; use serenity::model::prelude::ChannelId; use std::collections::HashSet; use std::sync::Arc; pub st...
const MSG_ON_BLOCK:i32=1; //作用域为整个文件 //let temp:i32 =1; //error:let声明的局部变量只能在{}内声明使用 mod test; mod utils; use test::test_struct::*; use test::test_enum::*; use test::test_closures::*; use test::test_generics::*; use test::test_trait::*; use test::*; use std::collections::HashMap; fn main() { // println!(...
#![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; #[allow(clippy::many_single_char_names)] mod helpers; #[allow(clippy::many_single_char_names)] mod offchain; #[allow(clippy::many_single_char_names)] mod shuffle; #[allow(clippy::many_single_char_names)] mod dkg; #[allow(clippy::many_single_char_names)...
extern crate bacon_rajan_cc; pub mod context; pub mod error; pub mod iter; pub mod lexer; pub mod parser; pub mod position; pub mod stdlib; pub mod value;
//! The `std::generator` module. use crate::{ContextError, Generator, Module, Protocol}; /// Construct the `std::generator` module. pub fn module() -> Result<Module, ContextError> { let mut module = Module::with_crate_item("std", &["generator"]); module.ty::<Generator>()?; module.generator_state(&["Genera...
use winapi::shared::minwindef::{WPARAM, LPARAM}; use winapi::um::winuser::{ES_AUTOVSCROLL, ES_AUTOHSCROLL, WS_VISIBLE, WS_DISABLED, WS_TABSTOP, WS_VSCROLL, WS_HSCROLL}; use crate::win32::window_helper as wh; use crate::win32::base_helper::check_hwnd; use crate::win32::richedit as rich; use crate::{Font, NwgError}; use ...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn serialize_structure_create_access_point_input( input: &crate::input::CreateAccessPointInput, writer: smithy_xml::encode::ElWriter, ) { #[allow(unused_mut)] let mut scope = writer.finish(); if let Some(var_1) = &i...
use crate::{RegisterBits, Register}; use core::marker; /// A 8-bit timer. pub trait Timer8 : Sized { /// The first compare register. /// For example, OCR0A. type CompareA: Register<T=u8>; /// The second compare register. /// For example, OCR0B. type CompareB: Register<T=u8>; /// The count...
use std::fmt; use std::error::Error; use super::{ Ix, }; /// An error that can be produced by `.into_shape()` #[derive(Clone, Debug)] pub enum ShapeError { /// incompatible shapes in reshape, (from, to) IncompatibleShapes(Box<[Ix]>, Box<[Ix]>), /// incompatible layout: not contiguous IncompatibleLa...
use quote::{ToTokens}; use crate::layouts::{LayoutChild, FlexboxLayoutChild, GridLayoutChild, layout_parameters}; use crate::events::ControlEvents; use crate::shared::Parameters; const TOP_LEVEL: &'static [&'static str] = &[ "Window", "MessageWindow", "ExternCanvas" ]; const AUTO_PARENT: &'static [&'static str] =...
use firefly_rt::function::ErlangResult; use firefly_rt::term::{ListBuilder, OpaqueTerm}; use crate::env; use crate::scheduler; extern "C-unwind" { #[allow(improper_ctypes)] #[allow(improper_ctypes_definitions)] #[link_name = "init:boot/1"] fn boot(argv: OpaqueTerm) -> ErlangResult; } /// This functio...
#[doc = "Reader of register SR3"] pub type R = crate::R<u32, super::SR3>; #[doc = "Writer for register SR3"] pub type W = crate::W<u32, super::SR3>; #[doc = "Register SR3 `reset()`'s with value 0"] impl crate::ResetValue for super::SR3 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
/* origin: FreeBSD /usr/src/lib/msun/src/s_cosf.c */ /* * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. * Optimized by Bruce D. Evans. */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPr...
/// ```rust,ignore /// 326. 3的幂 /// /// 给定一个整数,写一个函数来判断它是否是 3 的幂次方。 /// /// 示例 1: /// /// 输入: 27 /// 输出: true /// /// 示例 2: /// /// 输入: 0 /// 输出: false /// /// 示例 3: /// /// 输入: 9 /// 输出: true /// /// 示例 4: /// /// 输入: 45 /// 输出: false /// /// 进阶: /// 你能不使用循环或者递归来完成本题吗? /// /// 来源:力扣(LeetCode) /// 链接:https://leetcode-c...
mod game; use game::*; fn main() { Game::new().play(); }
//! This module contains helper types/functions to output //! the literals and constructors for types that don't implement ToTokens. use as_derive_utils::to_token_fn::ToTokenFnMut; use quote::{quote, ToTokens, TokenStreamExt}; /// Constructs an RSlice constant. pub fn rslice_tokenizer<'a, I, T>(iter: I) -> impl ToTo...
use std::f32; use std::fs::File; use std::io::Write; use std::vec::Vec; // use std::f32::{INFINITY, NEG_INFINITY}; use image::{GrayImage, RgbaImage}; static INF: f32 = 9999.0; pub struct SDF { output_image_path: String, outline: f32, img: GrayImage, img_size: (u32, u32), pixel_count: usize, ...
/* @author: xiao cai niao @datetime: 2019/11/22 */ use actix_web::{web}; use std::sync::{mpsc, Arc, Mutex}; use crate::storage::rocks::{DbInfo, KeyValue, CfNameTypeCode, PrefixTypeCode}; use crate::storage::opdb::HostInfoValue; use crate::ha::{DownNodeInfo, get_node_state_from_host}; use crate::ha::procotol; use std::...
pub mod book; pub mod general;
#![feature(const_fn)] #![feature(const_fn_union)] #![feature(type_alias_impl_trait)] #![feature(untagged_unions)] const fn transmute<T, U>(from: T) -> U { use std::mem::ManuallyDrop; union Transform<FROM, INTO> { from: ManuallyDrop<FROM>, into: ManuallyDrop<INTO>, } let transformer = ...
use model::*; pub trait Strategy { fn act(&mut self, me: &Robot, rules: &Rules, game: &Game, action: &mut Action); }
use serde::{Deserialize, Serialize}; use crate::decode::Decode; use crate::encode::{Encode, IsNull}; use crate::error::BoxDynError; use crate::sqlite::{ type_info::DataType, Sqlite, SqliteArgumentValue, SqliteTypeInfo, SqliteValueRef, }; use crate::types::{Json, Type}; impl<T> Type<Sqlite> for Json<T> { fn ty...
pub use { chunk::*, chunk_handle::*, chunk_map::*, chunk_map_limits::*, chunk_map_limits::*, chunk_map_system::*, chunk_moore_neighborhood::*, chunk_repo::*, consts::*, heightmap::*, heightmap_generator::*, load_areas::*, structures_generator::*, vec::*, vec_proto::*, vox::*, vox_type::*, }; mod chunk;...
//! Decoding of [literals] in the surface language into Rust datatypes. //! //! [literals]: https://en.wikipedia.org/wiki/Literal_%28computer_programming%29 use crossbeam_channel::Sender; use logos::Logos; use num_traits::{Float, PrimInt, Signed, Unsigned}; use crate::lang::Location; use crate::reporting::LiteralPars...
use std::collections::HashMap; use std::collections::HashSet; use std::fs; use std::vec; fn question_1() { let filename = "inputs/q1_input.txt"; let contents = fs::read_to_string(filename).expect("Could not read the file"); let mut numbers: Vec<i64> = contents .lines() .into_iter() ...
// # The Rust Programing Language // // Using a hash map and vectors, create a text interface to allow a user to add employee names to // a department in a company. For example, “Add Sally to Engineering” or “Add Amir to Sales.” Then // let the user retrieve a list of all people in a department or all people in the com...
use rule::Rule; #[test] fn at_most() { let code = "yyy"; let y = Rule::new(|_, _| Ok(14)); y.literal("y"); let test1: Rule<i32> = Rule::default(); test1.at_most(2, &y); if let Ok(_) = test1.scan(&code) { assert!(false); } else { assert!(true); ...
//! This crate provides three derive macros for [`rust-iost`] traits. //! //! # Examples //! //! ``` //! use rust_iost::{Read, Write, NumberBytes}; //! //! #[derive(Read, Write, NumberBytes, PartialEq, Debug)] //! #[iost_root_path = "crate"] //! struct Thing(u8); //! //! let thing = Thing(30); //! //! // N...
mod somemod; trait Trait {} pub fn f() { let x = Box::new(0u32); let y: &Trait = x; // ^ERR expected &Trait, found // ^ERR mismatched types // ^NOTE expected type `&Trait` // ^NOTE(<1.16.0) found type // ^HELP(>=1.18.0,<1.24....
//! Generic functions for working with (primarily nucleic acid) sequences use std::borrow::Cow; use memchr::memchr2; use crate::bitkmer::BitNuclKmer; use crate::kmer::{CanonicalKmers, Kmers}; /// Transform a nucleic acid sequence into its "normalized" form. /// /// The normalized form is: /// - only AGCTN and possi...
extern crate cgmath; extern crate collision; extern crate rhusics_core; extern crate rhusics_ecs; extern crate shrev; extern crate specs; use cgmath::{Point3, Quaternion, Rad, Rotation3, Transform, Vector3}; use collision::dbvt::query_ray_closest; use collision::Ray3; use shrev::EventChannel; use specs::prelude::{Buil...
use crate::jre::Jre; use crate::launcher::Launcher; use crate::util::launcher_dir; use anyhow::{Context, Result}; use std::path::Path; use crate::config::Config; use std::fs; mod config; mod jre; mod launcher; mod util; enum Stage { Launcher, DownloadJre, CheckDownload, CheckExtract, } pub fn main()...
#![feature(test)] extern crate hlife; extern crate rand; extern crate test; use hlife::Hashlife; use rand::thread_rng; use test::Bencher; fn bench_random_at_depth(n: usize, b: &mut Bencher) { //assert!(n > 0); let mut rng = thread_rng(); Hashlife::with_new(|hl| { b.iter(|| hl.big_step(hl.random_b...
#[doc = "Reader of register AHB3RSTR"] pub type R = crate::R<u32, super::AHB3RSTR>; #[doc = "Writer for register AHB3RSTR"] pub type W = crate::W<u32, super::AHB3RSTR>; #[doc = "Register AHB3RSTR `reset()`'s with value 0"] impl crate::ResetValue for super::AHB3RSTR { type Type = u32; #[inline(always)] fn re...
// 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 (c) 2021 Quark Container Authors / 2018 The gVisor Authors. // // 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 ...
use std::env; use std::io; use std::io::prelude::*; use std::fs::File; #[derive(Debug)] enum Error { Io(io::Error), Program(&'static str), } impl From<io::Error> for Error { fn from(e: io::Error) -> Error { Error::Io(e) } } impl From<&'static str> for Error { fn from(e: &'static str) -> E...
#![no_std] //#![deny(warnings)] use embedded_hal as hal; pub use cortex_a; pub use embedded_time as time; pub use nb; pub use pine64 as pac; pub mod ccu; pub mod delay; pub mod display; pub mod dma; pub mod gpio; pub mod prelude; pub mod serial; pub mod timer;
//! Functions for XORing byte arrays pub fn xor(a: &[u8], b: &[u8]) -> Box<[u8]> { if a.len() != b.len() { panic!("Xoring vectors of different lengths"); } let result: Vec<u8> = a.iter().zip(b).map(|(x, y)| x ^ y).collect(); result.into_boxed_slice() } pub fn rep_key_xor(input: &[u8], key: &...
use im::{self, HashMap}; use std::collections::HashSet; #[derive(Eq, PartialEq, Hash, Debug, Clone, Copy)] pub struct Position { pub x: u8, pub y: u8, } impl Position { pub fn all() -> impl Iterator<Item = Position> { (1..=9).flat_map(|y| (1..=9).map(move |x| Position { x, y })) } pub fn r...
//! Module folding evaluates imports with known argument at compile-time. //! //! This is similar to [constant folding], but for the `builtinUseModule` //! builtin. This is also similar to [inlining], but for entire module contents. //! //! Here's a before-and-after example of an import of Core being folded: //! //! ``...
use super::Material; use crate::rtrs::textures::Texture; use crate::Color; use crate::HitRecord; use crate::Point; use crate::Ray; use crate::Vector; use std::sync::Arc; #[derive(Debug)] pub struct Metal { pub albedo: Arc<dyn Texture>, pub fuzz: f64, } impl Metal { pub fn new(albedo: Arc<dyn Texture>, fuz...
extern crate arrange; use arrange::IntRange; fn main() { let ir = IntRange::new(1, 10, 1).range(); println!("{:?}", ir); assert_eq!(ir, &[1, 2, 3, 4, 5, 6, 7, 8, 9]); }
mod with_float_minuend; mod with_integer_minuend; use proptest::prop_assert; use proptest::strategy::Just; use liblumen_alloc::erts::process::Process; use liblumen_alloc::erts::term::prelude::*; use crate::erlang::subtract_2::result; use crate::test::strategy; use crate::test::with_process; #[test] fn without_numbe...
use super::super::gl; pub struct CullFaceState { cull_face: gl::GLenum, enabled: bool, } impl CullFaceState { pub fn build_initialized() -> Self { let state = Self { cull_face: gl::FRONT_AND_BACK, enabled: true, }; state.upload(); state } ...
use rucaja::{JvmAttachment, JvmClass, JvmMethod, JvmObject, JvmString, jvalue_from_jobject}; use std::ptr::null; /// pub struct Graph<'a> { // The JVM. jvm_attachment: &'a JvmAttachment, // The wrapper JVM class from our fat JAR. wrapper_class: JvmClass<'a>, // Methods from that wrapper class. ...
//! An ImageLayer represents an image or a snapshot of a segment at one particular LSN. //! It is stored in a file on disk. //! //! On disk, the image files are stored in timelines/<timelineid> directory. //! Currently, there are no subdirectories, and each image layer file is named like this: //! //! Note that segno i...
#[doc = "Description cluster[n]: Last result is equal or above CH[n].LIMIT.HIGH"] pub struct LIMITH { register: ::vcell::VolatileCell<u32>, } #[doc = "Description cluster[n]: Last result is equal or above CH[n].LIMIT.HIGH"] pub mod limith; #[doc = "Description cluster[n]: Last result is equal or below CH[n].LIMIT.L...
mod lists; use std::convert::TryFrom; use pest::Parser; use pest::iterators::Pair; use errors; use types::{Value, ValuePtr, Atom, Symbol, Fixnum, Str, Boolean}; use self::lists::{cons, reverse}; #[derive(Parser)] #[grammar = "schematic.pest"] struct ExampleParser; impl From<String> for Symbol { fn from(s: Stri...
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "std")] pub use std::os::raw as ctypes; #[cfg(all(not(feature = "std"), feature = "no_std"))] pub mod ctypes { // The signedness of `char` is platform-specific, however a consequence ...
mod bar; mod canvas; mod color_button; mod note; use gtk4::prelude::*; use note::Note; fn main() { let application = gtk4::Application::new( Some("com.github.gtk-rs.examples.paintable"), Default::default(), ); application.connect_activate(build_ui); application.run(); } fn build_ui(appl...
extern crate futures; use futures::*; fn forty_two() -> BoxFuture<i32,()> { done(Ok(42)).boxed() } fn times_two(v: i32) -> BoxFuture<i32, ()> { finished(v * 2).boxed() } fn main() { forty_two() .and_then(|v| times_two(v)) .map(|v| println!("v: {}", v)) .forget(); }
use argparse::{ArgumentParser, StoreTrue}; use nickel::*; use types::{ServerOptions}; use logger::{Logger}; use error_handler::{error_handler}; use handler::{router}; use session::{ServerData}; use nickel_session::{Session, CookieSession}; pub fn run(mut opts : &mut ServerOptions) -> Nickel<ServerData> { ...
#![feature(test)] extern crate test; #[macro_use] extern crate crypto_bench; #[allow(dead_code, non_camel_case_types, non_upper_case_globals, non_snake_case)] mod ffi; mod aesgcm; mod chachapoly; // mod sha;
// 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 crate::bind_library; use crate::bind_program; use crate::dependency_graph::{self, DependencyGraph}; use crate::make_identifier; use crate::parser_commo...
use crate::errors::{MelodyErrors, MelodyErrorsKind}; use crate::song::{Playlist, Song}; use num_integer::div_mod_floor; use std::fs; use std::io::ErrorKind as IoErrorKind; use std::path::{Path, PathBuf}; use std::time::Duration; use walkdir::WalkDir; /// Helper function to format `Duration` to a string pub fn fmt_dura...
fn main() { println!("Hello, world!"); } fn get_input() -> String { use std::io::{stdin,stdout,Write}; let mut s=String::new(); let _=stdout().flush(); stdin().read_line(&mut s).expect("Did not enter a correct string"); if let Some('\n')=s.chars().next_back() { s.pop(); } if...
use log::info; use winit::{event::{ElementState, KeyboardInput, MouseButton, VirtualKeyCode}, window::Window}; use winit::event::WindowEvent; use wgpu::{BufferDescriptor, BufferUsage, Label, util::DeviceExt}; use futures::executor::block_on; use crate::setting::Setting; pub struct State { pub surface: wgpu::Surfa...
fn main() { //_string_slices(); _array_slices(); } // --------------------------- fn _array_slices() { let a = [1, 2, 3, 4, 5]; let _slice = &a[1..3]; } // --------------------------- fn _string_slices() { let s = String::from("hello world"); let s2 = "bye world"; let word = first_wor...
#![feature(horizon_thread_ext)] use ctru::prelude::*; use std::os::horizon::thread::BuilderExt; use std::time::Duration; fn main() { ctru::use_panic_handler(); let apt = Apt::new().unwrap(); let mut hid = Hid::new().unwrap(); let gfx = Gfx::new().unwrap(); let _console = Console::new(gfx.top_scr...
// 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 agreed to ...
use super::*; use std::rc::Rc; #[derive(Clone, Default)] struct Env { parent: Option<Rc<Env>>, clo: Option<Closure>, } impl Env { fn lookup(&self, idx: usize) -> Option<&Closure> { if idx == 0 { return self.clo.as_ref(); } self.parent.as_ref()?.lookup(idx - 1) } ...
use std::fmt::Debug; use std::cell::RefCell; trait Drawable: Debug { fn draw(&self); } #[derive(Debug)] struct Font { c: char } impl Drawable for Font { fn draw(&self) { print!("{}", self.c); } } #[derive(Debug)] struct Paragraph<'a> { letters: RefCell<Vec<&'a Drawable>> } impl<'a> Pa...
pub mod api; pub mod ctx; pub mod playground;
// Copyright 2016 `multipart` Crate Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed exce...
use std::collections::HashMap; use std::marker::PhantomData; use std::iter; use std::slice; use std::ops; pub trait Id<T> { fn id(&self) -> &str; } #[derive(Derivative, Debug)] #[derivative(Copy(bound = ""), Clone(bound = ""), PartialEq(bound = ""), Eq(bound = ""), Hash(bound = ""))] pub struct Idx<T...
use nanocv::{ImgBuf, ImgSize, Img}; use nanocv::filter::{resize_nearest_new}; use std::cmp::max; use crate::message::Rgba; pub fn resize(source: &ImgBuf<Rgba>, target_size: ImgSize) -> ImgBuf<Rgba> { if target_size.x == 0 || target_size.y == 0 || source.size().x == 0 || source.size().y == 0 { return ImgBuf...
#[macro_use] extern crate prettytable; extern crate crypto; extern crate dirs; extern crate reqwest; extern crate rpassword; extern crate rustc_serialize; extern crate structopt; #[macro_use] extern crate serde_json; mod data; mod header; use data::{ Activite, Blih, BlihData, BlihResponse, Board, Document, Home,...
// 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 failure::{Error, ResultExt}; use fidl::endpoints::{RequestStream, ServerEnd}; use fidl_fuchsia_amber::{self, ControlMarker as AmberMarker, ControlProxy...
/// Declare some items as requiring the "std" feature flag. macro_rules! with_std { ($($item:item)*) => { $( #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] $item )* } }
#![crate_name = "charon_driver"] #![crate_type = "dylib"] #![crate_type = "rlib"] extern crate syntax; extern crate trans; use syntax::parse::parser::{Parser}; use trans::base::translate; pub fn run(args: Vec<String>) -> i32{ run_compiler(); 0 } fn run_compiler(){ let mut p = Parser::new("break".to_string()); le...
use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; // 木が2部グラフであることを利用する // その際綺麗に1対1に分割されるとは限らないことに注意する fn main() { let n: usize = parse_line().unwrap(); let mut paths: Vec<Vec<usi...
//! GUI thread running GTK window and widgets mod window; mod pixbuf; mod components; mod file_dialogs; pub use window::build_ui;
use hdbconnect::{Connection, HdbResult}; #[rustfmt::skip] pub fn main() -> HdbResult<()> { // Get a connection let url = "hdbsql://HORST:SECRET@hxehost:39013"; let connection = Connection::new(url)?; // Cleanup if necessary, and set up a test table connection.multiple_statements_ignore_err(vec![ ...
// 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, format_err, Error}; use fidl::endpoints::ServiceMarker; use fidl_fuchsia_ui_input as uii; use fidl_fuchsia_ui_input2 as ui_input; use f...
use super::*; use proptest::strategy::Strategy; #[test] fn without_list_or_bitstring_second_returns_first() { run!( |arc_process| { ( strategy::term::is_list(arc_process.clone()), strategy::term(arc_process.clone()) .prop_filter("second canno...
use crate::tuple::take::TupleTake; /// Concatenate tuples. /// /// ## Examples /// ``` /// use fntools::tuple::concat::TupleConcat; /// /// assert_eq!((1, false).concat(("hell", 666)), (1, false, "hell", 666)); /// assert_eq!((0,).concat(((),)), (0, ())); /// ``` /// Any tuple concatenated with () won't change: /// ``...
use crate::app::Args; use anyhow::Result; use clap::Parser; use filter::SequentialSource; use maple_core::paths::AbsPathBuf; use matcher::{Bonus, MatchResult}; use rayon::iter::ParallelBridge; use std::borrow::Cow; use std::io::BufRead; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use types::Clap...
use super::{Entry, Leaf}; use crate::Metadata; use alloc::collections::btree_map::Entry::*; use alloc::collections::BTreeMap; pub(super) struct DuplicateName; pub(super) struct FoundLeaf; /// Node in a directory tree. #[derive(Debug)] pub(super) struct DirBuilder { /// Immediate files, symlinks or directories in ...
extern crate term; use std::cmp::{max, min}; use std::fmt::{Display, Error, Formatter}; #[derive(Debug)] pub struct ErrorContext { lines: Vec<(String, usize, usize)>, line: usize, column: usize, } #[derive(Debug)] pub struct CompileError { pub context: Option<ErrorContext>, pub msg: String, } im...
use crate::key::TypedKey; use std::collections::HashMap; use std::convert::TryInto; use thiserror::Error; use serde::{Deserialize, Serialize}; use crate::{key::Key, DataStore, Object}; use crate::ds::PutObjError; use crate::object::ObjType; use crate::dir; #[derive(Debug)] pub struct Commit { tree: TypedKey<di...
extern crate crypto; use crypto::vigenere::byte_utils; use crypto::vigenere::byte_utils::{HEX,Decodable,Encodable}; use crypto::vigenere; use std::env; const cypher_text : &str = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736"; fn main() -> std::io::Result<()>{ let bytes: Vec<u8> = cypher_...
use crate::backend::Backend; use anyhow::{bail, format_err, Context, Result}; use std::fs; use std::io::Write; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use tempfile::tempdir; /// Split a shell command into its parts, e.g. "python D:\\foo" will become ["Python", "D:/Foo"] pub fn split_shell_...
extern crate rustc_serialize; extern crate utils; extern crate chrono; extern crate hyper; extern crate xml; use std::collections::{HashMap, HashSet}; type TimeStamp = chrono::NaiveDateTime; // chrono::DateTime<chrono::FixedOffset>; #[derive(RustcDecodable, Default, Debug, Clone)] struct StopArea { id: i32, ...
use state::*; use storyboard::*; pub struct EmptyState; impl State<StoryboardContext> for EmptyState { fn update(&mut self, _dt: f32, _context: StateData<StoryboardContext>) -> StoryTrans { Trans::None } fn state_name(&self) -> String { "EmptyState".to_owned() } }
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors. // // 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 ...
use super::*; use proptest::arbitrary::any; use crate::erlang::binary_to_integer_2; use crate::runtime::binary_to_string::binary_to_string; #[test] fn without_base_base_errors_badarg() { crate::test::with_integer_integer_without_base_base_errors_badarg(file!(), result); } #[test] fn with_base_base_returns_binar...
pub struct Solution; impl Solution { pub fn get_hint(secret: String, guess: String) -> String { let x = secret.as_bytes(); let y = guess.as_bytes(); let mut bull = 0; let mut xcount = vec![0; 10]; let mut ycount = vec![0; 10]; for i in 0..x.len() { if x[i...
extern crate rand; use rand::Rng; use rand::distributions::range::{Range, SampleRange}; use rand::distributions::IndependentSample; use std::collections::{ BTreeMap, btree_map, VecDeque, vec_deque, }; pub enum GameObject { Food, Wall, } #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] ...
use std::f64::consts::PI; use rand::Rng; use crate::ray::Ray; use crate::vec3::Vec3; pub struct Camera { lower_left_corner: Vec3, horizontal: Vec3, vertical: Vec3, origin: Vec3, lens_radius: f64, u: Vec3, v: Vec3, w: Vec3, } impl Camera { pub fn new(look_from: Vec3, look_at: Vec3...
#[cfg(all(not(target_arch = "wasm32"), test))] mod test; use anyhow::*; use liblumen_alloc::erts::exception; use liblumen_alloc::erts::term::prelude::*; use crate::runtime::context::term_try_into_one_based_index; #[native_implemented::function(lists:keyfind/3)] pub fn result(key: Term, index: Term, tuple_list: Term...
// Copyright (c) 2016 DWANGO Co., Ltd. All Rights Reserved. // See the LICENSE file at the top-level directory of this distribution. //! Time related functionalities. pub mod timer { //! Timer use std::time; use std::sync::mpsc as std_mpsc; use futures::{Future, Poll, Async}; use internal::io_poll...
// TODO: wait for io stabilization and completely rewrite it use std::{io, str}; use std::borrow::Borrow; use std::collections::{HashSet, HashMap}; use sat::formula::{Var, Lit, VarMap}; use sat::Solver; pub fn write<W : io::Write, S : Solver>(_ : &mut W, _ : &S) -> io::Result<()> { // TODO: implement unimplem...
/* * @lc app=leetcode.cn id=509 lang=rust * * [509] 斐波那契数 * * https://leetcode-cn.com/problems/fibonacci-number/description/ * * algorithms * Easy (65.25%) * Likes: 70 * Dislikes: 0 * Total Accepted: 27.9K * Total Submissions: 42.8K * Testcase Example: '2' * * 斐波那契数,通常用 F(n) 表示,形成的序列称为斐波那契数列。该数列由 ...
/* * hurl (https://hurl.dev) * Copyright (C) 2020 Orange * * 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 ...
use std::cell::RefCell; use std::fmt::{self, Formatter}; use std::path::PathBuf; use std::rc::Rc; use log::{error, warn}; use serde::de::{Error as SerdeError, MapAccess, Visitor}; use serde::{self, Deserialize, Deserializer}; use unicode_width::UnicodeWidthChar; use winit::keyboard::{Key, KeyLocation, ModifiersState};...
mod with_map; use proptest::prop_assert_eq; use proptest::strategy::Strategy; use proptest::test_runner::{Config, TestRunner}; use liblumen_alloc::atom; use liblumen_alloc::erts::term::prelude::*; use crate::maps::keys_1::result; use crate::test::strategy; use crate::test::with_process_arc; #[test] fn without_map_e...
use std::{cell::Cell, time::Duration}; use xidlehook_core::{timers::CallbackTimer, Action::*, Xidlehook}; const TEST_UNIT: Duration = Duration::from_millis(50); #[test] fn disabled_timers_test() { let _ = env_logger::builder().is_test(true).try_init(); let triggered = Cell::new(0); let mut timer = Xidle...