text stringlengths 8 4.13M |
|---|
use std::collections::HashMap;
use std::collections::HashSet;
use incrementalmerkletree::*;
use pedersen::PedersenDigest;
use base::*;
use c2p::*;
use p2c::*;
use std::collections::VecDeque;
use convert::*;
#[derive(Clone)]
pub struct SenderProof {
pub proof: String,
//hb:([u64;4],[u64;4]),
pub coin: Strin... |
use glam::Vec2;
use legion::prelude::Entity;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Moving {
pub base_speed: f32,
pub target: MoveTarget,
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[allow(dead_code)]
pub enum MoveTarget {
None,
Location(Vec2),
Entity(Entity),
}
|
struct Point {
x: i32,
y: i32,
}
fn main() {
let p = Point { x: 0, y: 7 };
// A way of destructuring. The names of the fields must match the names of the fields in the
// struct
let Point { x, y } = p;
println!("{}", x);
println!("{}", y);
let Point { x: alter_x, y: alter_y } = p;
... |
// This file is part of syslog2. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/syslog2/master/COPYRIGHT. No part of syslog2, including this file, may be copied, modified, propagated, or distributed except... |
use std::collections::BTreeMap;
use model::business::Ticker;
/// Records of all stocks values
pub struct Stocks {
values : BTreeMap<String, Vec<f32>>
}
impl Stocks {
pub fn new() -> Stocks {
Stocks { values: BTreeMap::new() }
}
pub fn push(&mut self, ticker: &Ticker, value: f32) {
if ... |
pub trait TimeFormatter {
/// Converts an integer representing nanoseconds to a human-readable string.
fn format_as_time(&self) -> String;
}
const MICROSECOND: u64 = 1_000;
const MILLISECOND: u64 = MICROSECOND * 1_000;
const SECOND: u64 = MILLISECOND * 1_000;
const MINUTE: u64 = SECOND * 60;
#[allow(clippy::cast_... |
use prelude::*;
struct ReactCommand;
impl Command for ReactCommand {
fn execute(&self, _ctx: &mut Context, msg: &Message, _args: Args) -> CommandResult {
let _ = msg.react("1⃣");
let _ = msg.react("2⃣");
let _ = msg.react("3⃣");
Ok(())
}
}
pub fn register_command(sf: StandardFramework) -> Standar... |
// Copyright 2020. 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... |
fn main(){
// hello world.
println!("Hello World");
// print format.
println!("Today is {month}/{day}",
month=4.to_string(), day=22.to_string() );
}
|
#![doc(html_root_url = "https://docs.rs/tokio-sync/0.1.6")]
#![deny(missing_debug_implementations, missing_docs, unreachable_pub)]
#![cfg_attr(test, deny(warnings))]
//! Asynchronous synchronization primitives.
//!
//! This crate provides primitives for synchronizing asynchronous tasks.
extern crate fnv;
#[macro_use]... |
use rocket::response::Response;
use rocket_contrib::json::Json;
#[derive(Deserialize)]
pub struct NewChallengeRequest{
title: String,
topic: String,
image: String,
description: String,
}
#[post("/new_challenge", data = "<request>")]
pub fn new_Challenge(request: Json<NewChallengeRequest>, con: MainDbCon,
) -> R... |
use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000000007;
fn alphabet2idx(c: char) -> usize {
if c.is_ascii_lowercase() {
c as u8 as usize - 'a' as u8 as usize
} else if c... |
use crate::H256;
#[derive(Debug, Clone)]
pub enum Error {
MissingKey(H256),
}
pub type Result<T> = ::std::result::Result<T, Error>;
|
// See LICENSE file for copyright and license details.
use std::f32::consts::{PI, FRAC_PI_2};
use std::num::{pow, abs};
use cgmath::{Vector2, Vector3, Vector};
use core::types::{MInt, MapPos};
use core::misc::{rad_to_deg};
use visualizer::types::{WorldPos, MFloat, VertexCoord};
pub const HEX_EX_RADIUS: MFloat = 1.0;
... |
// Copyright (c) 2016 <daggerbot@gmail.com>
// This software is available under the terms of the zlib license.
// See README.md for more information.
mod app;
mod module;
mod os;
pub use app::AppContext;
pub use module::{ModuleInfo, ModuleQuery, ModuleQueryFn};
pub const GAME_ID: &'static str = "monster-battle";
pub... |
use super::errors::Error;
use super::eval::eval_term;
use super::Validator;
use crate::flat::PrimitiveSubtype::*;
use crate::flat::*;
use crate::lexer::Span;
use crate::raw::{IntLiteral, Spanned};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::convert::TryFrom;
pub fn type_check(
term: Spanned<&Te... |
use std::{fmt::Display, sync::Arc};
use datafusion::{
config::ConfigOptions, execution::runtime_env::RuntimeEnv, prelude::SessionConfig,
};
use object_store::ObjectStore;
use url::Url;
// The default catalog name - this impacts what SQL queries use if not specified
pub const DEFAULT_CATALOG: &str = "public";
// T... |
use legion::*;
pub struct Events<T> {
pub events: Vec<T>,
}
impl<T> Default for Events<T> {
fn default() -> Self {
Self {
events: Vec::new(),
}
}
}
impl<T> Events<T> {
pub fn send(&mut self, event: T) {
self.events.push(event);
}
}
#[system]
pub fn clear_event... |
pub mod dirs_index;
pub mod http;
|
use nrf51;
use cortex_m;
use cortex_m::interrupt::{Mutex};
use cortex_m_semihosting::hio::{HStdout};
use core::cell::RefCell;
//mod peripherals;
use boards::board::Board;
use boards::peripherals::leds::Led;
use boards::peripherals::buttons::Button;
use boards::peripherals::timers::Timer;
pub static HSTDOUT: Mutex<R... |
#![cfg_attr(not(feature = "std"), no_std)]
#![no_implicit_prelude]
#[cfg(feature = "alloc")]
extern crate alloc;
#[allow(clippy::eq_op)]
mod assert_eq {
#[cfg(feature = "alloc")]
use ::alloc::string::{String, ToString};
#[cfg(feature = "std")]
use ::std::string::{String, ToString};
#[test]
fn... |
//! The HTTP implementation serves the frontend
use futures::{Async::*, Future, Poll, future};
use http::response::Builder as ResponseBuilder;
use http::{Request, Response, StatusCode, header};
use hyper::{Body, service::Service, header::{HeaderValue, CONTENT_TYPE}};
use hyper_staticfile::{Static, StaticFuture};
use s... |
// 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 ... |
use failure::Error;
use yew::{html, Callback, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::services::fetch::StatusCode;
use yew::services::fetch::FetchTask;
use crate::services::froovie_service::{FroovieService, MovieSearch};
pub struct MovieSearchModel {
froovie: FroovieService,
callb... |
use std::fmt;
use std::rc::Rc;
use crate::platform::traits::*;
use crate::platform::Iterator as PlatformIterator;
use crate::platform::Manager as PlatformManager;
use crate::{Batteries, Battery, Result};
/// Manager for batteries available in system.
///
/// Allows fetching and updating [batteries] information.
///
/... |
// Copyright 2020 - 2021 Alex Dukhno
//
// 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... |
struct TableRow {
id: i32,
name: String,
admin: bool,
}
pub struct App {
table: Vec<TableRow>,
}
pub enum Msg {}
impl yew::Component for App {
type Message = Msg;
type Properties = ();
fn create(_: &yew::Context<Self>) -> Self {
App {
table: vec![
Tabl... |
pub mod ptr;
pub mod place;
pub mod value;
pub mod analyze;
pub mod pass;
pub mod trans;
pub mod error;
use error::Error;
use lowlang_syntax as syntax;
use lowlang_syntax::layout::TyLayout;
pub use cranelift_module::{Backend, Module, FuncId, DataId};
use cranelift_frontend::FunctionBuilder;
use cranelift_codegen::ir::... |
//! Checker tests, that require a Solver instance, so they cannot be unit tests of the
//! varisat-checker crate.
use anyhow::Error;
use proptest::prelude::*;
use varisat::{
checker::{Checker, ProofTranscriptProcessor, ProofTranscriptStep},
dimacs::write_dimacs,
CnfFormula, ExtendFormula, Lit, ProofForma... |
use std::collections::{HashMap, BinaryHeap, HashSet};
use std::cmp::Ordering;
use std::fmt::Debug;
use rand::distributions::{Exp, Distribution};
use ordered_float::OrderedFloat;
pub type State = HashMap<Place, PlaceState>;
pub type Place = usize;
pub type Time = f64;
#[derive(Debug, Copy, Clone)]
pub struct PlaceSt... |
// 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::{run_data_test, InfluxRpcTest};
use async_trait::async_trait;
use futures::{prelude::*, FutureExt};
use influxdb_storage_client::tag_key_bytes_to_strings;
use std::sync::Arc;
use test_helpers_end_to_end::{
maybe_skip_integration, DataGenerator, GrpcRequestBuilder, MiniCluster, StepTestState,
};
#[tokio:... |
use std::collections::BTreeSet;
enum States {
A,
B,
C,
D,
E,
F,
}
fn tasks(n: i32) -> i32 {
let mut tape = BTreeSet::new();
let mut state = States::A;
let mut pos = 0i32;
for _ in 0..n {
let x = tape.contains(&pos);
let (x2, pos2, state2) = matc... |
//! Performs a sword attack
use amethyst::{
core::timing::Time,
ecs::{Component, DenseVecStorage, Entities, Join, System, WriteStorage, Read},
};
pub struct DelayedRemove {
pub current: f32,
pub end: f32,
}
impl Component for DelayedRemove {
type Storage = DenseVecStorage<Self>;
}
impl DelayedRemo... |
use anyhow::Result;
use rocket::http::{Cookies, Status};
use rocket::response::{status::Custom, Response};
use rocket::Rocket;
use rocket_contrib::json::Json;
use serde_json::Value;
use crate::core::users::{entity::User, repository};
use crate::api::catchers::*;
use crate::utils::{db::DbConn, get_session_id};
#[p... |
//! This module contains implementations for the storage gRPC service
//! implemented in terms of the [`QueryNamespace`](iox_query::QueryNamespace).
use super::{TAG_KEY_FIELD, TAG_KEY_MEASUREMENT};
use crate::{
data::{
fieldlist_to_measurement_fields_response, series_or_groups_to_frames, tag_keys_to_byte_v... |
use proptest::prop_assert_eq;
use proptest::strategy::{Just, Strategy};
use liblumen_alloc::erts::term::prelude::*;
use crate::erlang::size_1::result;
use crate::test::strategy;
#[test]
fn without_tuple_or_bitstring_errors_badarg() {
run!(
|arc_process| {
(
Just(arc_process.cl... |
#![allow(unused)]
include!(concat!(env!("OUT_DIR"), "/glue.rs"));
|
use std::{path::PathBuf, str::FromStr};
use structopt::StructOpt;
pub trait TypeExtension {
fn extension(&self) -> &'static str;
}
#[derive(Debug, Copy, Clone)]
pub enum CompressionType {
Gzip,
Bzip,
Detect,
None,
}
impl TypeExtension for CompressionType {
fn extension(&self) -> &'static str ... |
use crate::interface::{
RedeemStakeBatch, StakeBatch, TimestampedNearBalance, TimestampedStakeBalance, YoctoNear,
};
use near_sdk::serde::{Deserialize, Serialize};
/// View model for a registered account with the contract
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(crate = "near_sdk::serde")]
pub struc... |
// 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 ... |
#![feature(path_ext)]
#![feature(fs_walk)]
#![feature(convert)]
extern crate rustc_serialize;
use std::path::Path;
use std::fs::PathExt;
use std::env;
use std::fs;
use std::process;
use std::fs::File;
use std::io::Write;
use std::io::Read;
use rustc_serialize::json;
#[derive(RustcDecodable, RustcEncodable)]
pub st... |
mod backend;
mod file_handle;
pub use file_handle::FileHandle;
mod dialog;
#[cfg(not(target_arch = "wasm32"))]
pub use dialog::FileDialog;
pub use dialog::AsyncFileDialog;
pub use dialog::{AsyncMessageDialog, MessageButtons, MessageDialog, MessageLevel};
|
//
// atom2.rs
// Copyright (C) 2019 Malcolm Ramsay <malramsay64@gmail.com>
// Distributed under terms of the MIT license.
//
use std::fmt;
use nalgebra::Point2;
use serde::{Deserialize, Serialize};
use crate::traits::Intersect;
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
pub struct Atom2 {
pub p... |
use crate::prelude::*;
use crate::api;
use crate::config;
use crate::repo;
use crate::models;
use chrono::prelude::*;
use actix_web::{get, web, App, HttpServer, HttpResponse, Responder};
#[derive(Clone)]
pub struct Node {
conf: config::Settings,
repo: repo::Repo,
ip: String,
}
const METADATA_URL: &str = ... |
use std::cell::{Cell, RefCell};
use std::cmp;
use std::convert::TryFrom;
use std::fs;
use std::io::prelude::*;
use std::io::{self, SeekFrom};
use std::marker;
use std::path::Path;
use crate::entry::{EntryFields, EntryIo};
use crate::error::TarError;
use crate::other;
use crate::pax::*;
use crate::{Entry, GnuExtSparseH... |
#[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::HB8CFG2 {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, ... |
//! Defines an interface for register-like actors (via [`RegisterMsg`]) and also provides
//! [`RegisterActor`] for model checking.
#[cfg(doc)]
use crate::actor::ActorModel;
use crate::actor::{Actor, Envelope, Id, Out};
use crate::semantics::register::{Register, RegisterOp, RegisterRet};
use crate::semantics::Consiste... |
extern crate rustl;
use rustl::foo;
fn main() {
let some_struct = rustl::display::AStructInYoRust{zeroth: 0};
println!("{}", some_struct);
foo::foo();
rustl::lol(10);
}
|
enum A {
Zero,
One,
Two()
}
fn main() {
println!("{} {} {}", A::Zero as usize, A::One as usize, A::Two as usize);
}
|
pub mod display;
pub mod pixel;
pub use sdl2;
#[cfg(test)]
mod tests {
extern crate rand;
use super::*;
use display::DisplayBuilder;
use rand::prelude::*;
use sdl2::audio::{AudioCallback, AudioSpecDesired};
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
struct SquareWave {
... |
use std::{io, error};
mod fibonacci;
mod temperature;
mod carol;
mod collections;
enum Options {
Temperature,
Fibonacci,
GoldenFibonacci,
Carol,
IntegerList,
PigLatin,
Employee,
}
fn main() -> Result<(), Box<dyn error::Error>> {
loop {
println!("Choose one of the following pro... |
extern crate iron;
extern crate router;
extern crate markdown;
extern crate rustc_serialize;
use std::error::Error;
use std::fs::File;
use std::path::Path;
use std::convert::From;
use rustc_serialize::{
Decodable,
Decoder
};
use iron::prelude::*;
use iron::status;
use iron::headers::{
ContentType
};
use i... |
///! Error types for startuppong apis
extern crate hyper;
extern crate rustc_serialize;
use std::io;
use std::fmt;
use std::convert::From;
use std::error::Error;
use rustc_serialize::json;
/// The error type returned in a startuppong `Result`.
#[derive(Debug)]
pub enum ApiError {
/// An ID was not found for the... |
pub struct Solution;
impl Solution {
pub fn count_battleships(board: Vec<Vec<char>>) -> i32 {
let mut count = 0;
for i in 0..board.len() {
for j in 0..board[i].len() {
if board[i][j] == 'X'
&& (i == 0 || board[i - 1][j] == '.')
&& ... |
use crate::{source::Source, CACHE};
use serde::{Deserialize, Serialize};
use std::{
collections::{btree_map::Entry, BTreeMap},
fs::File,
hash::{Hash, Hasher},
io::Write,
ops::Deref,
path::PathBuf,
u8,
};
impl Default for Library {
fn default() -> Self {
Self {
books:... |
use super::*;
#[test]
pub fn test_engine_disasm() {
struct Test {
arch: Arch,
mode: Mode,
opts: Vec<(Opt, usize)>,
code: Vec<u8>,
insn: Vec<Insn>,
};
let tests = vec![
Test{
arch: Arch::X86,
mode: MODE_16,
opts: vec![],
... |
//! Diffie-Hellman key exchange
use crate::keys::{PublicKey, SecretKey};
use mohan::tools::RistrettoBoth;
/// Alias type for a shared secret after ECDH
pub type SharedSecret = RistrettoBoth;
/// Perform a Diffie-Hellman key agreement to produce a `SharedSecret`.
pub fn diffie_hellman(secret: &SecretKey, their_public... |
use join::Join;
use next_permutation::NextPermutation;
use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let s: String = rd.get();
let k: usize = rd.get();
let mut s: Vec<char> = s.chars().collect();
s.sort();
for _ in... |
use crate::diesel::QueryDsl;
use crate::diesel::RunQueryDsl;
use crate::helpers::{email, email_template};
use crate::model::{Event, Space, SpaceUser, User};
use crate::schema::events::dsl::*;
use crate::schema::spaces::dsl::*;
use crate::schema::users::dsl::*;
use crate::Pool;
use actix::prelude::*;
use chrono::prelude... |
#[doc = "Reader of register TBPS"]
pub type R = crate::R<u32, super::TBPS>;
#[doc = "Reader of field `PSS`"]
pub type PSS_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - GPTM Timer A Prescaler Value"]
#[inline(always)]
pub fn pss(&self) -> PSS_R {
PSS_R::new((self.bits & 0xffff) as u16)
}
... |
use std::cmp::Ord;
use std::cmp::Ordering;
use std::convert::From;
use std::slice::Iter;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum InsertionResult {
Create,
Overwrite,
InvalidKey,
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum RemovalResult {
KeyNotFound,
Removed,
}
// Provides an or... |
use rust_mal_lib::env::{Env, Environment};
use rust_mal_lib::types::MalError;
use rust_mal_steps::scaffold::*;
fn read(string: String) -> String {
string
}
fn eval(ast: String) -> String {
ast
}
fn print(expr: String) -> String {
expr
}
struct Step0Repl;
impl InterpreterScaffold<Env> for Step0Repl {
... |
//main
//calls game from game/mod.rs
extern crate quicksilver;
pub mod game;
fn main() {
// call copied from qs:
// NOTE: Set HIDPI to 1.0 to get pixel-perfect rendering.
// Otherwise the window resizes to whatever value the OS sets and
// scales the contents.
// https://docs.rs/glutin/0.19.0/glu... |
use anyhow::Result;
use clap::Parser;
use qapi::qmp;
use super::{GlobalArgs, QmpStream};
#[derive(Parser, Debug)]
pub(crate) struct Status {
}
impl Status {
pub async fn run(self, qmp: QmpStream, _args: GlobalArgs) -> Result<i32> {
let status = qmp.execute(qmp::query_status { }).await?;
println!("VCPU Status: {:... |
use anyhow::{Context, Result};
use cargo_metadata::{
Metadata as CargoMetadata, Package as MetadataPackage, PackageId as MetadataId,
};
use std::{
collections::{btree_map, BTreeMap, BTreeSet},
path::{Path, PathBuf},
str::FromStr,
};
/// The minimal amount of package information we care about
///
/// T... |
//! Metrics for [`Loader`].
use std::sync::Arc;
use async_trait::async_trait;
use iox_time::TimeProvider;
use metric::{DurationHistogram, U64Counter};
use observability_deps::tracing::warn;
use parking_lot::Mutex;
use pdatastructs::filters::{bloomfilter::BloomFilter, Filter};
use super::Loader;
/// Wraps a [`Loader... |
pub mod queue;
pub mod user;
|
use piece::*;
use mask::*;
use sided_mask::*;
use std::ops::*;
use rank::*;
pub trait Side {
type Mask : SidedMask;
type Opposite : Side;
const PAWN : Piece;
const KNIGHT : Piece;
const BISHOP : Piece;
const ROOK : Piece;
const QUEEN : Piece;
const KING : Piece;
const RANGE : Rang... |
//! The Document interface represents any web page loaded in the browser
pub mod body_1;
pub mod create_element_2;
pub mod create_text_node_2;
pub mod get_element_by_id_2;
pub mod new_0;
use std::convert::TryInto;
use std::mem;
use anyhow::*;
use web_sys::Document;
use liblumen_alloc::erts::exception;
use liblumen_a... |
use std::fmt::Debug;
use std::time::Instant;
pub fn run_timed<T, X>(f: fn(T) -> X, argument: T, part: u64)
where
X: Debug,
{
let now = Instant::now();
let answer = f(argument);
println!(
"part {}: {:?}, result found in {} ms",
part,
answer,
now.elapsed().as_millis()
... |
pub mod component;
pub mod data_manager;
pub mod entity;
pub mod system;
pub mod world;
pub use self::component::Component;
pub use self::data_manager::DataManager;
pub use self::entity::Entity;
pub use self::system::System;
pub use self::world::World; |
/*
* Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei),
* find the minimum number of conference rooms required.
*
* Example 1:
* ----------
* Input: [[0, 30],[5, 10],[15, 20]]
* Output: 2
*
* Example 2:
* -----------
* Input: [[7,10],[2,4]]
* Output: ... |
pub(crate) use _sha256::make_module;
#[pymodule]
mod _sha256 {
use crate::hashlib::_hashlib::{local_sha224, local_sha256, HashArgs};
use crate::vm::{PyPayload, PyResult, VirtualMachine};
#[pyfunction]
fn sha224(args: HashArgs, vm: &VirtualMachine) -> PyResult {
Ok(local_sha224(args).into_pyobj... |
pub struct Solution;
impl Solution {
pub fn reverse(x: i32) -> i32 {
let mut x = x;
let mut y = 0i32;
while x != 0 {
if let Some(t) = y.checked_mul(10).and_then(|y| y.checked_add(x % 10)) {
y = t;
} else {
return 0;
}
... |
use super::utills::{get_points, started_check};
use colors::SUCCESS_COLOR;
use prelude::*;
use serenity::framework::standard::CreateGroup;
use store::UsersInfo;
use timeago::Formatter;
struct InfoCommand;
impl Command for InfoCommand {
fn execute(&self, ctx: &mut Context, msg: &Message, _args: Args) -> CommandResul... |
use super::SkewTContext;
use crate::{
app::config::{self},
coords::{Rect, ScreenCoords, ScreenRect, TPCoords, XYCoords},
gui::{DrawingArgs, PlotContextExt},
};
use gtk::cairo::Context;
use itertools::izip;
use metfor::{Celsius, HectoPascal, Knots, WindSpdDir};
struct WindBarbConfig {
shaft_length: f64,... |
use std::collections::HashMap;
use std::mem;
use cranelift::codegen::Context;
use cranelift::prelude::*;
use cranelift_module::{Linkage, Module};
use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder};
use crate::parser::{Ast, Expresion, OperationType, Statement, VariableID};
struct CodegenContext {
varia... |
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
use crate::*;
use std::collections::HashMap;
#[derive(Clone)]
pub struct Scores(HashMap<ScoreId, Score>);
impl Scores {
pub fn create_by_map(scores: HashMap<ScoreId, Score>) -> Self {
Scores(scores)
}
pub fn count(&self) -> usize {
self.0.len()
}
pub fn get(&self, song_id: &ScoreId... |
extern crate ekiden_tools;
fn main() {
ekiden_tools::generate_mod("src/generated", &["api"]);
ekiden_tools::build_api();
}
|
fn main() {
let x: i32 = 5;
let arr = [1, 2, 3];
for i in arr.iter() {
}
if i == 7 {
println!("{} is equal to 7", i);
} else {
println!("{} is smaller than 7", i)
}
println!("{:?}", x);
}
|
pub use crate::other::*;
pub type size_t = libc::size_t;
pub type __int32_t = libc::c_int;
pub type pid_t = libc::pid_t;
pub type time_t = libc::time_t;
pub type uint32_t = libc::c_uint;
pub type iconv_t = *mut libc::c_void;
pub type dev_t = libc::dev_t;
pub type blkcnt_t = libc::blkcnt_t;
pub type blksize_t = libc::b... |
fn main() {
let s1 = String::from("hello");
let len = calculate_length(&s1); // s1 is borrowed
println!("The length of '{}' is {}", s1, len);
let mut s2 = s1; //s1 is moved, use clone if want to copy
change(&mut s2);
let len = calculate_length(&s2);
println!("The length of '{}' is {}", s... |
//! This module implements the `remote` CLI command
use influxdb_iox_client::connection::Connection;
use thiserror::Error;
mod partition;
mod store;
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Error)]
pub enum Error {
#[error("{0}")]
Partition(#[from] partition::Error),
#[error("{0}")]
Stor... |
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ../gir-files
// DO NOT EDIT
use crate::Address;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box... |
// 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::{Error, ResultExt},
fidl_fuchsia_modular::{
ExecuteResult, ExecuteStatus, PuppetMasterRequest, PuppetMasterRequestStream, St... |
// 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 na::{Isometry3, Point3, Unit, Vector3};
#[derive(Debug, Copy, Clone)]
pub struct Ray {
pub origin: Point3<f32>,
pub direction: Unit<Vector3<f32>>,
}
impl Ray {
pub fn apply_isometry(&self, isometry: Isometry3<f32>) -> Self {
Self {
origin: isometry.transform_point(&self.origin),
direction: U... |
use firefly_diagnostics::*;
use firefly_pass::Pass;
use firefly_syntax_base::*;
use crate::ast::*;
/// Registers auto-imported BIFs in the given module
///
/// This pass takes into account the compiler options of the module when deciding what to import
pub struct AddAutoImports;
impl Pass for AddAutoImports {
typ... |
use anyhow::Context;
use std::{
io::{BufRead, BufReader},
ops::Range,
};
const INPUT: &[u8] = include_bytes!("input.txt");
fn partition(seat: &str, range: Range<u32>) -> Option<u32> {
match seat.as_bytes().first() {
Some(b'F') | Some(b'L') => {
partition(&seat[1..], range.start..((rang... |
/***********************************************************************************************************************
* Copyright (c) 2019 by the authors
*
* Author: André Borrmann
* License: Apache License 2.0
*****************************************************************************************************... |
//! This crate includes [`Canvas`] type, which provides basic drawing methods for [`Rectangle`] and
//! [`Line`], with label or not.
use std::cmp::{max, min};
use std::{mem, str};
type Vertex = (usize, usize);
/// Defines a rectangle with four boundaries.
#[derive(Debug)]
pub struct Rectangle {
pub left: usize,
... |
extern crate geo;
use geo::{Coordinate, Point};
fn main() {
let c = Coordinate {
x: 40.02f64,
y: 116.34,
};
let p = Point(c);
let Point(coord) = p;
println!("Point at ({}, {})", coord.x, coord.y);
}
|
// TODO: no_std
extern crate cpuid;
#[macro_use]
extern crate quick_error;
extern crate semver;
#[cfg(unix)]
mod unix;
#[cfg(unix)]
use unix::{PlatformError, total_memory};
#[cfg(unix)]
pub use unix::os;
#[cfg(windows)]
mod windows;
#[cfg(windows)]
use windows::{PlatformError, total_memory};
#[cfg(windows)]
pub us... |
use gary_zmq::cluster_communication::ZmqNode;
// use std::collections::HashMap;
use chrono::{DateTime, Utc};
use std::collections::HashMap;
use std::sync::mpsc::{Receiver, Sender};
use std::sync::{Arc, Mutex};
pub fn start_node(
sender: Sender<&'static str>,
_receiver: Receiver<&str>,
host_addr: &str,
... |
// Copyright (c) 2020 Sam Blenny
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
#![forbid(unsafe_code)]
/// Frame buffer bounds
pub const WORDS_PER_LINE: usize = 11;
pub const WIDTH: usize = 336;
pub const LINES: usize = 536;
pub const FRAME_BUF_SIZE: usize = WORDS_PER_LINE * LINES;
/// Frame buffer of 1-bit pixels... |
use generic_array::{ArrayLength, GenericArray};
use spade::{PointN, SpadeNum, TwoDimensional};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
pub type VertexId = usize;
pub type Weight = f64;
pub type Real = f64;
#[derive(Debug)]
pub struct Edge {
pub ta... |
#[doc = "Reader of register ITLINE14"]
pub type R = crate::R<u32, super::ITLINE14>;
#[doc = "Reader of field `TIM1_CC`"]
pub type TIM1_CC_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 0 - TIM1_CC"]
#[inline(always)]
pub fn tim1_cc(&self) -> TIM1_CC_R {
TIM1_CC_R::new((self.bits & 0x01) != 0)
}... |
#[doc = "Reader of register CSR"]
pub type R = crate::R<u32, super::CSR>;
#[doc = "Reader of field `ADDRDY_MST`"]
pub type ADDRDY_MST_R = crate::R<bool, bool>;
#[doc = "EOSMP_MST\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EOSMP_MST_A {
#[doc = "0: End of sampling phase no yet reached"]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.