text
stringlengths
8
4.13M
/* chapter 4 syntax and semantics */ fn main() { // here, the String created // will be dropped immediately, // as it’s not bound: let _ = String::from(" hello ").trim(); } // output should be: /* */
fn main() { let a: i16 = 5; let b: i16 = 18; let c: i64 = 5; let d: i64 = 18; let e: i32 = 5; let f: i32 = 18; println!("{}", a + b); println!("{}", c + d); println!("{}", e + f); }
use crate::Result; use parking_lot::Mutex; use std::{sync::Arc, thread}; pub type JoinHandle = thread::JoinHandle<Result<()>>; #[derive(Clone)] pub struct ThreadHandle(Arc<Mutex<Option<JoinHandle>>>); impl Default for ThreadHandle { fn default() -> Self { Self(Arc::new(Mutex::new(None))) } } impl Th...
use std::path::{Path, PathBuf}; use notify::{watcher, DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher}; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::time::Duration; #[salsa::query_group(VfsDatabaseStorage)] trait VfsDatabase: salsa::Database + FileWatcher { fn...
pub mod sparse_array; pub mod array_queue; pub mod circle_array_queue; pub mod single_linked_list; pub mod double_linked_list; pub mod circle_single_linked_list;
#![feature(phase, globs)] #[phase(plugin, link)] extern crate log; #[phase(plugin, link)] extern crate regex_macros; extern crate regex; extern crate flate; extern crate chrono; extern crate serialize; extern crate irc = "rust-irclib"; use std::str::IntoMaybeOwned; pub use std::collections::HashMap; pub use userm...
use std::path::Path; use djanco::*; use djanco::data::*; use djanco::log::*; use djanco::csv::*; use djanco_ext::*; #[djanco(May, 2021, subsets(All))] pub fn my_query(database: &Database, _log: &Log, output: &Path) -> Result<(), std::io::Error> { database.projects() .group_by(project::Language) ...
#![allow(dead_code)] use shorthand::ShortHand; #[derive(ShortHand, Default)] struct Command { #[shorthand(enable(skip))] value: String, } fn main() {}
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// SyntheticsApiStep : The steps used in a Synthetics multistep API test. #[derive(Clone, Debug, Par...
use std::fmt; use std::fmt::Display; use failure::{Backtrace, Context, Fail}; use crate::model; pub type Result<T> = ::std::result::Result<T, Error>; #[derive(Fail, Debug)] pub enum ErrorKind { #[fail(display = "io error")] Io, #[fail(display = "config error")] Config, #[fail(display = "auth err...
#![cfg_attr(not(feature = "std"), no_std)] use dispatch::DispatchError; use frame_support::{ decl_event, decl_module, decl_storage, dispatch::{self, DispatchResult}, }; use rstd::vec::Vec; use system::ensure_signed; /// The pallet's configuration trait. pub trait Trait: system::Trait { /// The overarching event ty...
pub struct BfInterpreter { pub registers: Vec<u8>, pub pointer: usize, pub loop_markers: Vec<usize>, pub code_index: usize, } impl BfInterpreter { pub fn new() -> Self { BfInterpreter { registers: vec!(0), pointer: 0, loop_markers: vec!(), cod...
#![feature(exclusive_range_pattern)] extern crate minifb; use minifb::{Key, Window, WindowOptions}; use std::{env, io}; use std::io::prelude::*; use std::io::{stdin, stdout, Read, Write}; use std::fs::File; use rand::Rng; const PIXEL_WIDTH: usize = 64; const PIXEL_HEIGHT: usize = 32; const FOREGROUND_COLOR: u32 = 0x...
extern crate audio_clock; extern crate bela; extern crate euclidian_rythms; extern crate mbms_traits; extern crate monome; extern crate smallvec; extern crate musical_scales; use std::cmp; use std::fmt; use std::str::FromStr; use std::sync::mpsc::{channel, Receiver, Sender}; use std::{thread, time}; use audio_clock::...
/// ************************************************************************** /// Copyright (c) 2015 Osspial All Rights Reserved. /// /// This file is part of hidapi-rs, based on hidapi_rust by Roland Ruckerbauer. /// ************************************************************************* // For documentation look ...
use primitives::{Primitives, PolyType}; /// Triangulates the quads in a Primitive in the correct way for /// FB_ngon_encoding to reconstruct them. pub fn encode_ngons(mut prims: Primitives) -> Primitives { assert!(prims.poly_type == PolyType::TrisAndQuads); let mut tris = Vec::<u16>::with_capacity(prims.indic...
//! Defines the `SearchNode` trait. use uci::SetOption; use board::{Board, IllegalBoard}; use moves::{Move, MoveDigest, AddMove}; use depth::*; use value::*; use evaluator::Evaluator; use qsearch::QsearchResult; /// A trait for chess positions -- a convenient interface for the /// tree-searching algorithm. /// /// A...
use super::*; use crate::Name; impl<'a> Name<'a> for Document<'a> {} impl<'a> Name<'a> for Definition<'a> { fn name(&self) -> Option<&'a str> { match self { Definition::Operation(o) => o.name, Definition::Fragment(f) => Some(f.name), Definition::SelectionSet(_) => None,...
#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum ProcessStatus { /// The process is ready to run Ready, /// The process is running Running, /// The process exited normally with the given exit code. Exited(u8), /// The process was killed by the given signal. Signaled(nix::sys::sig...
use crate::{ commands::{MyCommand, MyCommandOption}, util::{ constants::{GENERAL_ISSUE, MESSAGE_TOO_OLD_TO_BULK_DELETE}, MessageExt, }, BotResult, CommandData, Context, Error, MessageBuilder, }; use std::{str::FromStr, sync::Arc}; use tokio::time::{self, Duration}; use twilight_http::{a...
use _const::{MOVE_BACK_RANGE, MOVE_FRONT_RANGE, MOVE_LEFT_RANGE, MOVE_RIGHT_RANGE}; use component::{Component, Position}; use entity::Entity; pub fn move_vec(position: &mut Position, new_position: &Position) { position.x = new_position.x; position.y = new_position.y; } pub fn move_frontward(position: &mut Pos...
use std::cmp::Ordering; use std::fmt; use std::hash::{Hash, Hasher}; use ed25519_dalek::{PublicKey, Signature}; use serde::Serialize; #[derive(Eq, Clone, Copy, Serialize)] pub struct Actor(pub PublicKey); impl PartialEq for Actor { fn eq(&self, other: &Self) -> bool { self.0 == other.0 } } impl Hash...
use std::fs; use std::str::FromStr; #[derive(Clone, Copy, PartialEq)] enum Tile { Open, Tree, } struct Map { map: Vec<Tile>, w: usize, h: usize, } impl FromStr for Map { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { let w = s.find('\n') .ok_or_e...
use nom::error::{ErrorKind, ParseError}; use nom::{Err, IResult, Parser}; pub(crate) fn many0<I, O, E, F>(mut f: F) -> impl FnMut(I) -> IResult<I, Vec<O>, E> where I: Clone + PartialEq, F: Parser<I, O, E>, E: ParseError<I>, { move |mut i: I| { let mut acc = Vec::with_capacity(4); loop {...
mod audio_format; mod region_of_interest; mod video_crop; mod video_format; mod video_scaling; pub use audio_format::AudioFormat; pub use region_of_interest::RegionOfInterest; pub use video_crop::VideoCrop; pub use video_format::VideoFormat; pub use video_scaling::VideoScaling;
use itertools::iproduct; use rand::{distributions::Uniform, rngs::StdRng, Rng, SeedableRng}; use std::ops::{Index, IndexMut}; use rayon::prelude::*; // A struct to contain the grid and the various metadata // The grid is 2d, but it is stored as a 1d vec. // Here are the rules: Each has a state n from 0..num_states // ...
use std::marker::PhantomData; use futures::prelude::*; pub struct BidirectionalPipe<A, B, E> where A: Stream, B: Stream, { buffer_a: Option<A::Item>, buffer_b: Option<B::Item>, side_a: A, side_b: B, stream_a_finished: bool, stream_b_finished: bool, _error_type: PhantomData<E>, } i...
mod short_msg_kat_128; mod short_msg_kat_160; mod short_msg_kat_224; mod short_msg_kat_256; mod short_msg_kat_key;
use crate::models; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct Kit { pub id: i32, pub serial: String, pub name: Option<String>, pub description: Option<String>, pub latitude: Option<f64>, ...
// Copyright 2019, 2020 Wingchain // // 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...
//! SML type checking. use sml::{Expression, Schema}; use std::collections::HashMap; use std::rc::Rc; /// The type checking environment stores the type of each variable that is in /// scope. #[derive(Clone, Debug)] pub struct Environment<'e> { pub parent: Option<&'e Environment<'e>>, pub variables: HashMap<R...
mod base64; fn main() { println!("Hello, world! = {:?}", ('=' as u8)); }
use errors::*; use repos::*; use sentry_integration::log_and_capture_error; use services::*; use diesel::{connection::AnsiTransactionManager, pg::Pg, Connection}; use failure::Fail; use futures::{future, prelude::*}; use futures_cpupool::CpuPool; use hyper::header::Authorization; use hyper::server::Request; use hyper:...
use super::super::super::super::{btn, modal}; use super::state::Modal; use super::Msg; use crate::{block::chat::item::Icon, model::PersonalData, Resource}; use kagura::prelude::*; mod common { pub use super::super::super::common::*; pub use super::super::common::*; } pub fn render(resource: &Resource, persona...
use crate::chunk::chunk_payload_data::ChunkPayloadData; use std::collections::VecDeque; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use tokio::sync::Mutex; /// pendingBaseQueue pub(crate) type PendingBaseQueue = VecDeque<ChunkPayloadData>; // TODO: benchmark performance between multiple Atomic+Mutex ...
fn main() { let p = 0 as *const i32; // let k = *p; // rust will not allow this unsafe { let k = *p; println!("{:?}", k); } }
use crate::storage; use crate::utils::{count_lines_from_path, StatefulList}; use crate::vec_of_strings; use phf; use std::collections::{HashMap, HashSet}; use std::fmt; use std::path::PathBuf; use tui::style::Color; pub const SCRIPT_SIGN: &'static str = "#!"; pub fn is_script(text: &str) -> bool { if text.len() <...
#[doc = "Register `CRYP_MISR` reader"] pub type R = crate::R<CRYP_MISR_SPEC>; #[doc = "Field `INMIS` reader - INMIS"] pub type INMIS_R = crate::BitReader; #[doc = "Field `OUTMIS` reader - OUTMIS"] pub type OUTMIS_R = crate::BitReader; impl R { #[doc = "Bit 0 - INMIS"] #[inline(always)] pub fn inmis(&self) -...
// Copyright 2020 lowRISC contributors. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
use std::fs::{File, OpenOptions}; use std::io::Write; use std::marker::PhantomData; use std::mem::replace; use std::path::{Path, PathBuf}; use anyhow::{anyhow, Result}; use arrow2::array::{Array, MutableArray, StructArray, TryExtend}; use arrow2::chunk::Chunk; use arrow2::datatypes::*; use arrow2::io::parquet::write::...
#[doc = "Register `I3C_BCR` reader"] pub type R = crate::R<I3C_BCR_SPEC>; #[doc = "Register `I3C_BCR` writer"] pub type W = crate::W<I3C_BCR_SPEC>; #[doc = "Field `BCR0` reader - max data speed limitation"] pub type BCR0_R = crate::BitReader; #[doc = "Field `BCR0` writer - max data speed limitation"] pub type BCR0_W<'a...
pub mod application; pub mod container; pub mod domain; pub mod infrastructure; pub mod mocks;
#[doc = "Reader of register ETH_MACPHYCSR"] pub type R = crate::R<u32, super::ETH_MACPHYCSR>; #[doc = "Writer for register ETH_MACPHYCSR"] pub type W = crate::W<u32, super::ETH_MACPHYCSR>; #[doc = "Register ETH_MACPHYCSR `reset()`'s with value 0"] impl crate::ResetValue for super::ETH_MACPHYCSR { type Type = u32; ...
use std::{ io, time::Duration, pin::Pin, task::{Context, Poll}, }; #[cfg(feature = "tokio_io")] use tokio::{net::TcpStream, io::ReadBuf}; #[cfg(feature = "tls")] use tokio_native_tls::TlsStream; #[cfg(feature = "tokio_io")] use tokio::io::{AsyncRead, AsyncWrite}; use pin_project::pin_project; #[cfg(fe...
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use super::{Node, NodeLabel, NodeList, NodePtr, StringLiteral}; /// Trait implemented by those who call the visit functionality. p...
use actix_web::{HttpResponse, Path}; use auth::user::User; use bigneon_db::models::*; use db::Connection; use errors::BigNeonError; use helpers::application; use models::PathParameters; pub fn index((conn, user): (Connection, User)) -> Result<HttpResponse, BigNeonError> { user.requires_scope(Scopes::OrderRead)?; ...
use serde::{Deserialize, Serialize}; /// Node ID of a query plan tree. #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Serialize, Deserialize, )] pub(crate) struct QueryPlanNodeId(u32); /// Monotonously increasing ID generator. #[derive(Eq, PartialEq, PartialOrd, Ord, Hash, Debug, Def...
use crate::db::transactions; use crate::graphql::Context; use crate::models::transaction::{NewTransaction, Transaction, UpdateTransaction}; use diesel::PgConnection; use juniper::{FieldError, FieldResult}; pub struct TransactionQuery; pub struct TransactionMutation; impl TransactionQuery { pub fn all(ctx: &Contex...
use dyn_clone::DynClone; use std::fmt::{self, Display}; use std::sync::{Arc, Mutex}; struct Log { id: u64, events: Arc<Mutex<Vec<String>>>, } impl Clone for Log { fn clone(&self) -> Self { Log { id: self.id + 1, events: self.events.clone(), } } } impl Display f...
#![allow(dead_code)] // trait // trait 中可以包含:函数、常量、类型等 // 成员方法 // trait 中可以定义函数 trait Shape { fn area(&self) -> f64; } // 所有的 trait 中都有一个隐藏的类型 Self,代表当前这个实现了此 trait 的具体类型 // trait 中定义的函数,也可以称作关联函数(associated function)。函数的第一个参数 // 如果是 Self 相关的类型,且命名为 self,这个参数可以被称为"receiver"(接收者)。 // 具有 receiver 参数的函数,我们称为"方法"(met...
use specs::*; use SystemInfo; use systems::handlers::packet::LoginHandler; use component::channel::*; use component::counter::*; pub struct InitKillCounters { reader: Option<OnPlayerJoinReader>, } #[derive(SystemData)] pub struct InitKillCountersData<'a> { pub channel: Read<'a, OnPlayerJoin>, pub total_kills: ...
use crate::import::*; use std::convert::Infallible; use serde::export::PhantomData; #[derive(Default)] pub struct Global<T> (pub T); impl<T: Unpin + Send + 'static> Actor for Global<T> { type Context = Context<Self>; } impl<T: Unpin + Send + 'static> Supervised for Global<T> {} impl<T: Default + Unpin + Send + ...
// Copy from https://github.com/actix/actix-web/blob/a3a78ac6fb50c17b73f9d4ac6cac816ceae68bb3/actix-files/src/lib.rs // to make it non-private use std::fs::File; use std::io::{Read, Seek}; use std::{cmp, io}; use actix_web::error::{BlockingError, Error, ErrorInternalServerError}; use actix_web::web; use actix_web::web...
mod utils; use assert_cmd::prelude::*; use std::io::Read; use std::process::Command; use structopt::clap::{crate_name, crate_version}; use surf; use utils::{Error, ProbyProcess}; /// Show help and exit. #[test] fn help_shows() -> Result<(), Error> { Command::cargo_bin("proby")? .arg("--help") .as...
use super::*; pub trait RenderBackend { } /// An openGL wrapper that is used to interface with openGL. pub struct GLContext; impl RenderBackend for GLContext { } impl GLContext{ /// Default debug message callback for opengl messages #[allow(unused_variables)] extern "system" fn gl_debug_message(sou...
use directory_client::metrics::MixMetric; use directory_client::requests::metrics_mixes_post::MetricsMixPoster; use directory_client::DirectoryClient; use futures::channel::mpsc; use futures::lock::Mutex; use futures::StreamExt; use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; const METRICS_...
use serde::{Deserialize, Serialize}; use std::fmt; // Message #[derive(Serialize, Deserialize, Debug)] pub struct Error { message: String, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.message) } }
#![cfg(test)] use problem1::{sum, dedup, filter}; use problem2::{mat_mult, Matrix}; use problem3::sieve; use problem4::{hanoi, Peg}; #[test] fn test_sum_empty() { let array = []; assert_eq!(sum(&array), 0); } #[test] fn test_sum_single() { let array = [1]; assert_eq!(sum(&array), 1); } #[test] fn t...
use std::collections::HashMap; use std::fmt; #[derive(Clone, Debug)] pub struct Container { pub name: String, pub runtime_id: String, } pub struct Connections { connections: HashMap<String, Connection>, container_instance_id_to_task_id_map: HashMap<String, Vec<String>>, instance_id_to_task_id_map:...
use std::{ collections::{hash_map, BTreeMap, HashMap}, fs, path::*, }; use ron; use serde::Serializer; use amethyst::{ core::{nalgebra::Vector3, transform::components::Transform}, ecs::{prelude::*, world::EntitiesRes,}, shred::DefaultProvider, }; use crate::{ entities::tile::TileTypes, ...
mod tokens { #[derive(Debug)] enum TokenType { // Single-character tokens. LeftParen, RightParen, KeftBrace, RightBrace, Comma, Dot, Minus, Plus, Semicolon, Slash, Star, // One or two character tokens. Bang, BangEqual, Equal, EqualEqual, Greater, GreaterEqual, Less, LessEqua...
#![deny(missing_docs)] //! Implementation of [Dancing Links](https://en.wikipedia.org/wiki/Dancing_Links) //! and [Algorithm X](https://en.wikipedia.org/wiki/Knuth%27s_Algorithm_X) for solving //! [exact cover](https://en.wikipedia.org/wiki/Exact_cover) problems. pub mod grid; pub mod latin_square; pub mod queens; p...
#[doc = "Register `DMA_HISR` reader"] pub type R = crate::R<DMA_HISR_SPEC>; #[doc = "Field `FEIF4` reader - FEIF4"] pub type FEIF4_R = crate::BitReader; #[doc = "Field `DMEIF4` reader - DMEIF4"] pub type DMEIF4_R = crate::BitReader; #[doc = "Field `TEIF4` reader - TEIF4"] pub type TEIF4_R = crate::BitReader; #[doc = "F...
// 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...
// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate 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 la...
// Copyright 2016 Google 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 in...
use std::fs; use regex::Regex; use std::collections::HashMap; use std::vec::Vec; pub fn solve() { println!("\n************* Day - 5 ******************"); let txtPath = [env!("CARGO_MANIFEST_DIR"), "/inputs/day5.input1.txt"].join(""); let contents = fs::read_to_string(txtPath).expect("err reading file");...
// .parse() will only take the type provided. So if parsing 30 and the type is float then // .parse() will throw an error as it's an int. That's the reason behind this terrible-ness // - Austin Haskell pub fn parse_possible_float(data: &str) -> f32 { let val: f32; if data.contains(".") { val = da...
fn main() { let number1; let number2 = 22; number1 = number2; print!("{}", number1); }
use crate::commitment::Commitment; use crate::config::Server; use std::time::Duration; cfg_default!( use tokio::sync::mpsc::{UnboundedSender, UnboundedReceiver, Sender, Receiver}; ); cfg_not_default!( use crossbeam::channel::{Sender, Receiver}; ); static MAX_FAILURE_SCALE: u64 = 12; static FAILURE_WAIT: Dura...
use hex; use base64; pub fn str_to_hex(s: &str) -> Result<Vec<u8>, hex::FromHexError> { hex::decode(s) } pub fn hex_to_base64(hex: &[u8]) -> String { base64::encode(hex) } pub fn fixed_xor(buf1: &[u8], buf2: &[u8]) -> Vec<u8> { // FIXME challenge specifies buffers are same length, never verified here ...
use specs::Join; pub struct AvoiderControlSystem; impl<'a> ::specs::System<'a> for AvoiderControlSystem { type SystemData = ( ::specs::ReadStorage<'a, ::component::Player>, ::specs::ReadStorage<'a, ::component::Aim>, ::specs::ReadStorage<'a, ::component::PhysicBody>, ::specs::Write...
#[doc = "Register `ADCPS1` reader"] pub type R = crate::R<ADCPS1_SPEC>; #[doc = "Register `ADCPS1` writer"] pub type W = crate::W<ADCPS1_SPEC>; #[doc = "Field `ADC1PSC` reader - ADC1PSC"] pub type ADC1PSC_R = crate::FieldReader; #[doc = "Field `ADC1PSC` writer - ADC1PSC"] pub type ADC1PSC_W<'a, REG, const O: u8> = crat...
use std::env; use std::fs; fn main() { let input_path: &String = &env::args().nth(1).unwrap(); let input_data = fs::read_to_string(input_path).unwrap(); let dimensions = 6 * 25; let mut layers: Vec<Vec<char>> = Vec::new(); let mut i = 0; while i + dimensions < input_data.len() { la...
use std::fmt; use chrono::{DateTime, Utc}; use chrono_humanize::Humanize; use owo_colors::OwoColorize; use serde::Deserialize; // #[derive(Debug, Default)] // pub struct Error { // pub detail: String, // } // // // // #[derive(Debug)] // pub struct Keyword { // pub crates_cnt: u64, // pub created_at: Stri...
pub struct Registers { pub a: u8, pub b: u8, pub c: u8, pub d: u8, pub e: u8, pub h: u8, pub l: u8, pub f: u8, pub pc: u16, pub sp: u16, } pub fn new() -> Registers { Registers { a: 1, b: 0, c: 19, d: 0, e: 216, ...
//! Error context system based on a thread-local representation of the call stack, itself based on //! the instructions that are sent between threads. use super::{AppInstruction, ASYNCOPENCALLS, OPENCALLS}; use crate::pty_bus::PtyInstruction; use crate::screen::ScreenInstruction; use std::fmt::{Display, Error, Format...
use std::ops::MulAssign; pub fn int_sqrt(x: u64) -> u64 { debug_assert!(x < 1 << 53); (x as f64).sqrt().floor() as u64 } pub trait PowGen { fn set_one(&mut self); fn square(&mut self); } pub fn pow_mut<T>(res: &mut T, f: &T, a: usize) where for<'a> T: MulAssign<&'a T>, T: Clone + PowGen, { ...
use std::io::{self, prelude::*}; use std::error::Error; use Symbol::{C, J}; /* Observation: can just ignore ?s - read in list of Cs and Js - X is cost of CJ, Y is cost of JC - compute number of CJs and JCs - one-pass, count up-edges and down-edges - dot-product with costs, and return todo: solve the extra-credi...
use regex::Regex; use std::fs::File; use std::io::Read; #[derive(PartialEq, Clone, Debug)] struct PasswordRequirement { lower_limit: usize, // min. number of times `required_char` must be present in `password` upper_limit: usize, // max. number of times `required_char` must be present in `password` require...
mod extensions; mod flatten_binary_expr; mod flatten_member_like_expr; pub use extensions::*; pub use flatten_binary_expr::*; pub use flatten_member_like_expr::*;
use actix_web::HttpResponse; use super::super::domain::developper::DomainDevelopper; use serde_derive::{ Deserialize, Serialize, }; #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct Developper { id: i32, good_total: i32, post_images: Vec<String>, user_id: i32, ...
#![no_std] #![no_main] use embedded_hal; use embedded_hal::digital::v2::{OutputPin}; use embedded_hal::blocking::delay::{DelayMs, DelayUs}; use embedded_hal::blocking::serial::Write; use nb; use riscv; use numtoa::NumToA; use arrayvec::ArrayString; extern crate panic_halt; use litex_pac as pac; use litex_hal as hal;...
//! The simplest possible example that does something. use std::{env, path}; use ggez; use ggez::event; use ggez::graphics; use ggez::nalgebra; use ggez::{Context, GameResult}; struct MainState { image: graphics::Image, } impl MainState { fn new(ctx: &mut Context) -> GameResult<MainState> { let s = ...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// IpRanges : IP ranges. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct IpRan...
use num_traits::{Zero, One}; use totsu_core::solver::{LinAlg, SliceLike}; use totsu_core::{LinAlgEx, splitm_mut}; pub fn trans_op<L, O>(op_size: (usize, usize), op: O, alpha: L::F, x: &L::Sl, beta: L::F, y: &mut L::Sl) where L: LinAlgEx, O: Fn(&L::Sl, &mut L::Sl) { let f0 = L::F::zero(); let f1 = L::F:...
// // RPushButton implementation // // Author: Dave Willmer // Licence: MIT Licence, 2015 // // use r_widget; // #[derive(RWidget, ViewableWidget)] pub struct RPushButton { id: i32, } impl RPushButton { pub fn new( text: &str ) -> RPushButton { RPushButton { id: 0 } } }
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// UsageLogsHour : Hour usage for logs. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] p...
/* * 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. */ //! Runs a process, gathering metadata about all of the processes that were ran //! and displays it...
#![cfg(feature = "parser")] //! Module for parsing the text representation of Azuki TAC into real code. //! //! An ANTLR specification of Azuki TAC's text representation can be found in //! `/docs/src/tac/AzukiTac.g4`. use std::{borrow::Cow, collections::BTreeMap, str::FromStr}; use crate::{ builder::FuncEditor, ...
use std::{ io::{Read, Write}, sync::Mutex, }; use crate::call_original; // todo: Use JSON for storing settings instead of the crap we have going on here. pub struct OptionInfo { pub title: &'static str, pub description: &'static str, pub value: bool, } impl OptionInfo { const fn new(title: &...
#[derive(Debug,Deserialize)] pub struct StreamsIdsResponse { continuation: Option<String>, pub ids: Vec<String>, } #[derive(Debug,Deserialize,PartialEq)] pub struct EntryDetailVisual { pub url: Option<String>, #[serde(rename="contentType")] pub content_type: Option<String>, } #[derive(Debug,Deserialize,Part...
#[doc = "Register `AHB2LPENR` reader"] pub type R = crate::R<AHB2LPENR_SPEC>; #[doc = "Register `AHB2LPENR` writer"] pub type W = crate::W<AHB2LPENR_SPEC>; #[doc = "Field `DCMILPEN` reader - DCMI peripheral clock enable during csleep mode"] pub type DCMILPEN_R = crate::BitReader<DCMILPEN_A>; #[doc = "DCMI peripheral cl...
/*===============================================================================================*/ // Copyright 2016 Kyle Finlay // // 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 // // ...
use std::fs::{File, read_dir}; use std::io::{BufRead, BufReader}; use time; use mongodb::{bson, doc, Document}; use mongodb::{Client, ThreadedClient}; use mongodb::db::ThreadedDatabase; use chrono::{DateTime, FixedOffset}; // use chrono::prelude::*;Duration, use regex::Regex; use std::path::{Path, PathBuf}; use std::...
$NetBSD: patch-src_tools_cargo_src_cargo_core_profiles.rs,v 1.14 2023/05/03 22:39:09 he Exp $ Turn off incremental builds for sparc64, ref. https://sources.debian.org/patches/cargo/0.29.0-1/2007_sparc64_disable_incremental_build.patch/ --- src/tools/cargo/src/cargo/core/profiles.rs.orig 2018-10-24 20:01:28.000000000 ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00..0x28 - Backup data register (BKP_DR)"] pub dr: [DR; 10], #[doc = "0x28 - RTC clock calibration register (BKP_RTCCR)"] pub rtccr: RTCCR, #[doc = "0x2c - Backup control register (BKP_CR)"] pub cr: CR, #[doc = "0x30...
#![crate_name = "rusticle"] #![feature(globs)] // For Regex #![feature(phase)] #[phase(plugin)] extern crate regex_macros; extern crate regex; extern crate debug; use types::utils; pub mod types; /// Open OBJ file, extract and print vertices and faces pub fn main() { let obj = utils::read_from_disk("cube.obj")...
#[macro_use] extern crate hyper; extern crate futures; extern crate tokio_core; use futures::Future; use futures::Stream; use hyper::{Client, Body, Uri, StatusCode}; use hyper::server::{Request, Response}; use hyper::client::HttpConnector; use hyper::Get; use tokio_core::reactor::Core; //use error::HttpError; use st...
/* chapter 4 syntax and semantics more than ownership */ fn main() { fn foo(n: Vec<i32>) -> Vec<i32> { // do stuff with n // hand back ownership n } let a = vec![1, 2, 3]; let b = foo(a); println!("{:?}", b); } // output should be: /* [1, 2, 3] */