blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
38a955bff3193724b142a26bc49c5b6999a650e1 | Rust | kubos/kubos | /examples/serial-comms-service/src/comms.rs | UTF-8 | 2,997 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | //
// Copyright (C) 2019 Kubos Corporation
//
// 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 agree... | true |
1a32e934a6033f99eca748528bad91054eb7195d | Rust | SOF3/count-write | /src/lib.rs | UTF-8 | 3,161 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | // count-write
// Copyright (C) SOFe
//
// 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 t... | true |
343d75acc1f0b06e95171ca012eb47162a29f8f5 | Rust | Aimnos/Dcoder-Challenges | /Easy/Rust/Learn Sum of Numbers.rs | UTF-8 | 244 | 2.75 | 3 | [
"MIT"
] | permissive | use std::io;
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
print!(
"{}",
buf.split_whitespace()
.fold(0, |acc, number| acc + number.parse::<u16>().unwrap())
);
}
| true |
db06a15cbd7838eaf1cb71c9bc59867f0dc1bca4 | Rust | cloud-hypervisor/rust-hypervisor-firmware | /src/cmos.rs | UTF-8 | 2,313 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | // SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2021 Akira Moroo
use atomic_refcell::AtomicRefCell;
use x86_64::instructions::port::{Port, PortWriteOnly};
static CMOS: AtomicRefCell<Cmos> = AtomicRefCell::new(Cmos::new());
struct Cmos {
address_port: PortWriteOnly<u8>,
data_port: Port<u8>,
reg_b:... | true |
df1fcb0c88285a1a5ae5e2b747999406c843de56 | Rust | kairosswag/aoc_2020 | /src/day09.rs | UTF-8 | 1,089 | 3.15625 | 3 | [] | no_license | #[aoc_generator(day9)]
pub fn generate(input: &str) -> Vec<u64> {
input
.lines()
.map(|l| l.parse::<u64>().expect("could not parse line"))
.collect()
}
#[aoc(day9, part1)]
pub fn part1(numbers: &[u64]) -> u64 {
'outer: for i in 25..numbers.len() {
for j in i - 25..i {
... | true |
98eca7a1831d42c4d9dbb2665316b2bade5b0312 | Rust | dylanmckay/protocol | /protocol/src/wire/middleware/rotate_bytes.rs | UTF-8 | 1,620 | 3.734375 | 4 | [
"MIT"
] | permissive | //! A fixed-offset based caesar cipher middleware.
use crate::{wire, Error};
use std::num::Wrapping;
/// Middleware that rotates each transmitted byte by a fixed offset.
///
/// **NOTE**: This is not really useful in real life.
#[derive(Copy, Clone, Debug)]
pub struct RotateBytes {
/// The integer offset to rota... | true |
b3cf35de5c0b494097022613fd255e895854313b | Rust | samhippie/rust_mc_cfr | /src/regret/regret_provider.rs | UTF-8 | 1,966 | 3.3125 | 3 | [
"MIT"
] | permissive | use std::error;
use crate::game::Player;
pub struct RegretResponse {
pub regret: Option<Vec<f32>>,
}
pub struct RegretRequest {
pub player: Player,
pub infoset_hash: u64,
pub handler: usize,
}
pub struct RegretDelta {
pub player: Player,
pub infoset_hash: u64,
pub regret_delta: Vec<f32>,... | true |
b47a6aadb2563d1e7ecc7fdc80c073c7c32aa7e7 | Rust | StructionSite/decimal-rs | /src/decimal.rs | UTF-8 | 36,597 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 CoD Technologies Corp.
//
// 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... | true |
a3eb0cec1d46cdbec0728894e8d2ef08e59fb382 | Rust | jackmead515/rust_paint | /src/shapes.rs | UTF-8 | 1,235 | 2.6875 | 3 | [] | no_license | extern crate piston;
extern crate graphics;
extern crate glutin_window;
extern crate opengl_graphics;
use piston::input::*;
use graphics::Context;
use opengl_graphics::{ GlGraphics };
pub struct Rect {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
pub rotation: f64,
pub color: [f32; 4]
}
impl ... | true |
ca92ede741827f26e6a67bc2d2fbbe499c1b76d2 | Rust | jlarsson89/eulersolutions | /010/src/main.rs | UTF-8 | 561 | 3.40625 | 3 | [
"MIT"
] | permissive | fn is_prime(n: i64) -> bool {
let x = (n as f64).sqrt() as i64 + 1;
if n < 2 {
return false;
}
if n < 4 {
return true;
}
for i in 2..x {
if n % i == 0 {
return false;
}
}
true
}
fn main() {
let mut i: i64 = 2;
let mut total: i64 = 0;
... | true |
86d1bbd718908170586074d269199175212602ed | Rust | Swordelf2/shifter | /src/game/physics/collider.rs | UTF-8 | 4,523 | 3.109375 | 3 | [] | no_license | use itertools::Itertools;
use smallvec::SmallVec;
use bevy::{
ecs::entity::Entity, math::Vec2, prelude::*,
transform::components::Transform,
};
use super::{
shape::{Shape, ShiftedShape},
util::{update_max_point, update_min_point},
BoundingBox,
};
/// Collision instance
#[derive(Copy, Clone, Debug... | true |
3593464f0172d7de74805005472807fcaa977e3e | Rust | TimoFreiberg/shopping-list | /shopping-list-server/src/repo/postgres.rs | UTF-8 | 5,294 | 2.703125 | 3 | [] | no_license | use std::path::Path;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use eyre::eyre;
use sqlx::migrate::Migrator;
use sqlx::{query, PgPool};
use sqlx::{query_as, FromRow};
use crate::{
model::Items,
repo::{IRepository, DEFAULT_LIMIT},
DoneItem, ItemId, OpenItem, Result,
};
pub struct PostgresR... | true |
90369e06044988a3a9ea71da16730c0d3436a984 | Rust | TimeSTEM/Tp3_tools | /tpx3/src/clusterlib.rs | UTF-8 | 25,033 | 2.578125 | 3 | [
"MIT"
] | permissive | //!`clusterlib` is a collection of tools to identify and manipulate TPX3 cluster.
pub mod cluster {
use crate::packetlib::{Packet, PacketEELS as Pack};
use crate::spimlib;
use crate::tdclib::PeriodicTdcRef;
use std::fs::OpenOptions;
use std::io::Write;
use std::ops::Deref;
use crate::constl... | true |
92ee46e826c65fc8c90d7853350c6dbf5ac822e2 | Rust | killertux/prevayler-rs | /examples/incrementer.rs | UTF-8 | 746 | 2.703125 | 3 | [] | no_license | use prevayler_rs::{
error::PrevaylerResult, serializer::JsonSerializer, Prevayler, PrevaylerBuilder, Transaction,
};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Increment {
increment: u8,
}
impl Transaction<u8> for Increment {
fn execute(self, data: &mut u8) {
*da... | true |
8ded99e892036fc0cd1cc6dcacbd4c3dcfe0af84 | Rust | ipfs-rust/xoodoo | /src/xoodoo/mod.rs | UTF-8 | 2,138 | 2.65625 | 3 | [
"MIT"
] | permissive | use rawbytes::RawBytes;
use zeroize::Zeroize;
#[cfg(not(target_arch = "x86_64"))]
mod impl_portable_x1;
#[cfg(target_arch = "x86_64")]
mod impl_x86_64_x1;
const ROUND_KEYS: [u32; 12] = [
0x012, 0x1a0, 0x0f0, 0x380, 0x02c, 0x060, 0x014, 0x120, 0x0d0, 0x3c0, 0x038, 0x058,
];
/// Xoodoo permutation parameterized ov... | true |
8675fd501fca85907616dd926ba09b5913be96ab | Rust | evantypanski/gremulator | /src/cpu/cpu.rs | UTF-8 | 33,628 | 3.109375 | 3 | [] | no_license | extern crate log;
use std::io::Error;
use self::log::{info, trace};
pub struct CPU {
pub registers: ::register::Registers,
mmu: ::mmu::MMU,
pub halted: bool,
}
impl CPU {
pub fn new() -> Result<CPU, Error> {
info!("Created new CPU");
let mmu = ::mmu::MMU::new()?;
Ok(CPU {
... | true |
65e6f53878eeacda88be87f5183b5a60a6a652b9 | Rust | larsjarlvik/wgpu-rs | /src/world/systems/sky/uniforms.rs | UTF-8 | 1,077 | 2.6875 | 3 | [] | no_license | use wgpu::util::DeviceExt;
#[repr(C)]
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
pub struct Uniforms {
pub light_dir: [f32; 3],
pub not_used: f32,
pub sky_color: [f32; 3],
}
pub struct UniformBuffer {
pub data: Uniforms,
pub buffer: wgpu::Buffer,
pub bind_group: wgpu::Bin... | true |
075ff9ff5032f8fb2e5c1fb0a13cbf4d16395624 | Rust | cgdilley/IntraLexicalComparison | /Code/LexMetrics/metrics.rs | UTF-8 | 4,499 | 3.046875 | 3 | [] | no_license | /*
* metrics.rs
*
* Language, Variation and Change
* Hauptseminar, WS16-17
* University of Tuebingen
*
* Christopher Dilley, Inna Pyrina, Erik Schill
*
* Part 1: Reading data, Levenshtein distances, Lexical metrics
* Author: Erik Schill
*/
use std::cmp::min;
use std::collections::HashMap;
use std::f6... | true |
08ec036d8e8937f8e313087161bdc57d13619cd5 | Rust | HaronK/aoc2019 | /task07_1/src/main.rs | UTF-8 | 3,012 | 3.328125 | 3 | [
"MIT"
] | permissive | use crate::intcode_comp::*;
use anyhow::{anyhow, ensure, Result};
use std::fs::File;
use std::io::{prelude::*, BufReader};
mod intcode_comp;
fn main() -> Result<()> {
let file = File::open("input.txt")?;
let reader = BufReader::new(file);
let prog_str = reader
.lines()
.nth(0)
.ok_... | true |
1e5eb783bb32d97d05ee9e62a92a0d9fd55dcc41 | Rust | rust-lang/rust | /tests/ui/borrowck/let_underscore_temporary.rs | UTF-8 | 1,355 | 2.765625 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // check-fail
fn let_underscore(string: &Option<&str>, mut num: Option<i32>) {
let _ = if let Some(s) = *string { s.len() } else { 0 };
let _ = if let Some(s) = &num { s } else { &0 };
let _ = if let Some(s) = &mut num {
*s += 1;
s
} else {
&mut 0
//~^ ERROR temporary va... | true |
82942c998c87d6b72dd1a981b36b49681a1d4cc3 | Rust | Xcode23/advent-of-code-2020 | /src/day7.rs | UTF-8 | 2,461 | 3.09375 | 3 | [] | no_license | use crate::input;
use std::collections::HashMap;
type BagData = HashMap<String, HashMap<String, i32>>;
pub fn outer_bags() -> i32 {
let data = parse_input(input::_INPUT);
data.iter().filter(|(x,_)| data.leads_to_gold((**x).as_str())).collect::<Vec<_>>().len() as i32
}
pub fn inner_bags() -> i32 {
let dat... | true |
d2d1d6e230f1bf9ba1f42eaa91678c072b3a4cd4 | Rust | NelsonKommander/Grupo-I | /fichas_de_estudo/rust/integral_trapezio_simples/src/main.rs | UTF-8 | 402 | 3.8125 | 4 | [] | no_license | fn func(x: f32) -> f32{
return 10.0*x-x*x;
}
fn trapezio(a: f32, b:f32, n:i32) -> f32 {
let mut sum = 0.0;
let h = (b-a)/(n as f32);
for i in 1..n {
let x = a+(i as f32)*h;
sum = sum + func(x as f32);
}
return h*(((func(a)+func(b))/2.0)+sum);
}
fn main() {
let trabalho;
... | true |
993aba98be9eb351573f7317f3a1f63dea4faf63 | Rust | jonfk/rust-sqlite-experiment | /diesel/src/repository.rs | UTF-8 | 2,551 | 2.953125 | 3 | [] | no_license | use crate::connection_pool::SqliteConnectionPool;
use diesel::prelude::*;
use failure::Error;
use log::info;
use schema::tasks;
#[derive(Insertable)]
#[table_name = "tasks"]
pub struct NewTask<'a> {
pub status: &'a str,
}
#[derive(Queryable, Debug, Clone)]
pub struct Task {
pub id: i32,
pub status: String... | true |
122a29ccc3de1907c454a6b68367301826a8438d | Rust | jgouly/keyboard-app | /src/scan.rs | UTF-8 | 1,462 | 3 | 3 | [] | no_license | use matrix::Matrix;
use matrix_config::MatrixConfig;
pub trait InputPin {
fn read_input(&self) -> u32;
}
pub trait OutputPin {
fn set_low(&self);
fn set_high(&self);
}
pub fn single_scan<'a, MC: MatrixConfig<'a>, RM: Matrix<T = u32>>(
conf: &'a MC,
) -> RM
where
MC::InputPin: InputPin,
MC::OutputPin: Out... | true |
00fec838b36991a53bab05bc041e36828490a50f | Rust | isgasho/console-gsoc | /console/src/ui/query.rs | UTF-8 | 7,081 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::filter::*;
use crate::ui::{Action, Input};
use tui::backend::CrosstermBackend;
use tui::layout::{Constraint, Direction, Layout, Rect};
use tui::style::{Color, Style};
use tui::widgets::{Block, Borders, Paragraph, Text, Widget};
use tui::Frame;
use std::borrow::Cow;
use std::cell::Cell;
pub struct QueryVie... | true |
a1ff5377e8a6fda182e0996c0dbe24b1863aba5c | Rust | philipc/rust-dwarf | /src/lib.rs | UTF-8 | 1,522 | 2.546875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod endian;
mod leb128;
mod read;
mod write;
pub mod abbrev;
pub mod constant;
pub mod die;
pub mod display;
pub mod elf;
pub mod line;
pub mod unit;
pub use endian::{AnyEndian, Endian, LittleEndian, BigEndian, NativeEndian};
pub use read::ReadError;
pub use write::WriteError;
#[derive(Debug)]
pub struct Sections<E:... | true |
7b2ede20e0ce84779aa266b0dfcdbf39bd98ce77 | Rust | Jimskapt/rust-book-fr | /FRENCH/listings/ch18-patterns-and-matching/listing-18-08/src/main.rs | UTF-8 | 150 | 2.875 | 3 | [
"Apache-2.0",
"MIT",
"Unlicense",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | fn main() {
let une_option_quelconque: Option<i32> = None;
// ANCHOR: here
let Some(x) = une_option_quelconque;
// ANCHOR_END: here
}
| true |
aaaf213b21f70784a8a59f3cd73b18b960bb3914 | Rust | bennyboer/cmd-args | /src/error.rs | UTF-8 | 945 | 3.1875 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub struct ParserError {
pub message: String,
}
impl Error for ParserError {}
impl fmt::Display for ParserError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.message)
}
}
impl From<std::str::ParseBoolError>... | true |
e98273b083656bf4900aae9ee079958137c9a341 | Rust | stakemori/hilbert_sqrt5 | /src/bignum.rs | UTF-8 | 13,533 | 2.921875 | 3 | [] | no_license | use libc::{c_ulong, c_long};
use gmp::mpz::Mpz;
use std::fmt;
use std::ops::{AddAssign, SubAssign, ShlAssign, ShrAssign, MulAssign};
use std;
use flint::fmpz_poly::FmpzPoly;
pub trait RealQuadElement<S> {
fn rt_part(&self) -> S;
fn ir_part(&self) -> S;
}
pub trait BigNumber {
fn is_zero_g(&self) -> bool;
... | true |
58ae948d52862c93fd3b0767731b43f0b7a9bdeb | Rust | liandashen/bat | /src/style.rs | UTF-8 | 2,937 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashSet;
use std::str::FromStr;
use crate::errors::*;
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
pub enum OutputComponent {
Auto,
Changes,
Grid,
Header,
Numbers,
Snip,
Full,
Plain,
}
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
pub enum OutputWrap {... | true |
6138b290a6fd952e1800b673a9d4d5c6df079be3 | Rust | emergent/ProjectEuler | /Rust/src/bin/015.rs | UTF-8 | 432 | 2.78125 | 3 | [
"Unlicense"
] | permissive | /// Problem 15 - Project Euler
/// http://projecteuler.net/index.php?section=problems&id=15
fn main() {
let n = 40;
let k = 20;
let mut c = vec![vec![0u64; n + 1]; n + 1];
for i in 0..=n {
for j in 0..=i {
if i == 0 || j == 0 {
c[i][j] = 1;
} else {
... | true |
04905c4f2f62d9f467eb6a1e5675d68c5fee7138 | Rust | marscore/hhvm | /hphp/hack/src/parser/syntax.rs | UTF-8 | 5,085 | 2.90625 | 3 | [
"Zend-2.0",
"PHP-3.01",
"MIT"
] | permissive | // Copyright (c) 2019, Facebook, Inc.
// All rights reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use crate::lexable_token::LexableToken;
use crate::syntax_kind::SyntaxKind;
use std::marker::Sized;
pub use crate::syntax_ge... | true |
783f5947a62bd11d651b767999fe562e0e857ddf | Rust | xunilrj/sandbox | /sources/rust/tomi/crates/tomi/src/main.rs | UTF-8 | 2,097 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | mod checksum_mapping;
mod commands;
mod formats;
mod parser;
mod utils;
use checksum_mapping::ChecksumMap;
use commands::{
convert_anm::ConvertAnmArgs, convert_chore::ConvertChoreArgs, convert_skl::ConvertSklArgs,
};
use log::debug;
use spinoff::{Color, Spinner, Spinners};
use structopt::StructOpt;
use user_error:... | true |
f8758acdde4f84caef6ddcf8b50f6fc71f4cb184 | Rust | hitmoon/raytracer | /src/hittable_list.rs | UTF-8 | 776 | 2.875 | 3 | [] | no_license | use crate::hittable::{HitRecord, Hittable};
use crate::ray::Ray;
#[derive(Debug)]
pub(crate) struct HittableList {
objects: Vec<Box<dyn Hittable>>,
}
impl HittableList {
pub(crate) fn new() -> Self {
Self { objects: vec![] }
}
pub(crate) fn add(&mut self, object: Box<dyn Hittable>) {
... | true |
803991743ed46faed63836eb27ced853d1e65fd7 | Rust | niclabs/AnyTrace | /ping/src/ping/reader.rs | UTF-8 | 6,227 | 2.703125 | 3 | [
"MIT"
] | permissive | extern crate pnet;
use pnet::packet::FromPacket;
use pnet::packet::Packet;
use pnet::packet::icmp::destination_unreachable::{DestinationUnreachable,
DestinationUnreachablePacket};
use pnet::packet::icmp::echo_reply::{EchoReply, EchoReplyPacket};
use pnet::packet::icmp:... | true |
16192387528d810f15aca7389707fba9d0af5197 | Rust | hhandika/simple-qc | /src/input.rs | UTF-8 | 4,634 | 2.6875 | 3 | [
"MIT"
] | permissive | //! Heru Handika
//! Module to process user inputs.
use std::path::PathBuf;
use std::sync::mpsc::channel;
use glob::glob;
use rayon::prelude::*;
use walkdir::WalkDir;
use crate::fasta;
use crate::fastq;
use crate::sequence::{FastqStats, FastaStats};
use crate::output;
pub fn traverse_dir(path: &str, iscsv: bool, f... | true |
f45724e774807fe915d482bb16651b31ddc42e2b | Rust | s3bk/pdf | /font/src/truetype.rs | UTF-8 | 1,707 | 2.765625 | 3 | [] | no_license | use std::error::Error;
use pathfinder_canvas::Path2D;
use pathfinder_geometry::vector::Vector2F;
use pathfinder_geometry::transform2d::Transform2F;
use stb_truetype::FontInfo;
use stb_truetype::VertexType;
use crate::{Font, Glyph};
pub struct TrueTypeFont<'a> {
pub info: FontInfo<&'a [u8]>
}
impl<'a> TrueTypeFont<... | true |
20ab4e490e63f4ab39ce760934317a9d1f49213a | Rust | marco-c/gecko-dev-wordified | /third_party/rust/futures-util/src/stream/stream/forward.rs | UTF-8 | 2,125 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use
crate
:
:
stream
:
:
Fuse
;
use
core
:
:
pin
:
:
Pin
;
use
futures_core
:
:
future
:
:
{
FusedFuture
Future
}
;
use
futures_core
:
:
ready
;
use
futures_core
:
:
stream
:
:
Stream
;
use
futures_core
:
:
task
:
:
{
Context
Poll
}
;
use
futures_sink
:
:
Sink
;
use
pin_project_lite
:
:
pin_project
;
pin_project
!
{
/
... | true |
9ae268d2348a6de147241706bbf7ab625ed9806a | Rust | iCodeIN/brainfuck-jit | /src/mode_0.rs | UTF-8 | 1,502 | 3.171875 | 3 | [] | no_license | use std::collections::HashMap;
pub fn build_matching_brackets_map(s: &[u8]) -> HashMap<usize, usize> {
let mut ip: usize = 0;
let mut open_brackets = Vec::new();
let mut idx_to_matching = HashMap::new();
while ip < s.len() {
match s[ip] as char {
'[' => open_brackets.push(ip),
... | true |
875e5311acf596921f4d8c018bfb9132ad526c6c | Rust | danleechina/Leetcode | /Rust_Sol/src/archive0/s241.rs | UTF-8 | 861 | 3.359375 | 3 | [] | no_license | struct Solution {}
impl Solution {
pub fn diff_ways_to_compute(input: String) -> Vec<i32> {
// println!("{}", input);
let mut res: Vec<i32> = Vec::new();
for (p, c) in input.chars().enumerate() {
if c == '+' || c == '-' || c == '*' {
let res_left = Solution::diff_ways_to_compute(input.chars... | true |
681e03ef87c1fd566777444c6a4859e63a102659 | Rust | pedrocr/wayland-rs | /wayland-client/src/env.rs | UTF-8 | 8,836 | 3.15625 | 3 | [
"MIT"
] | permissive | use EventQueueHandle;
use protocol::wl_registry::WlRegistry;
#[doc(hidden)]
pub trait EnvHandlerInner: Sized {
fn create(&WlRegistry, &[(u32, String, u32)]) -> Option<Self>;
}
/// Utility type to handle the registry and global objects
///
/// This struct provides you with a generic handler for the `wl_registry`
/... | true |
9e6343c3af9e849fd98cbe86daa1e98e24df2b6a | Rust | njhanley/adventofcode | /2022/08/part1.rs | UTF-8 | 1,329 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env rust-script
use std::collections::{HashMap, HashSet};
impl<T> Pipe for T {}
trait Pipe: Sized {
fn pipe<B, F>(self, f: F) -> B
where
F: FnOnce(Self) -> B,
{
f(self)
}
}
std::fs::read_to_string("input.txt")
.unwrap()
.lines()
.enumerate()
.pipe(|lines| {
let mut map = HashMap::new();
le... | true |
54eaa115700163316f685616f1f4a8805ebaab61 | Rust | songlinshu/elvis | /core/src/style/flex.rs | UTF-8 | 1,509 | 3.3125 | 3 | [
"MIT"
] | permissive | //! Flex Style
use crate::{
style::Style,
value::{
layouts::{Alignment, FlexBasis, FlexDirection, FlexWrap},
Unit,
},
};
use elvis_core_support::Setter;
/// `Flex` Style
#[derive(Clone, Default, Setter)]
pub struct FlexStyle {
/// Flex align
pub align: Option<Alignment>,
/// Fle... | true |
1f906bdff53227e8e0bbed8364ad5c70e3056418 | Rust | addictedcoder0/Rusty | /RustProg/rust_docs/rust_match/src/main.rs | UTF-8 | 2,158 | 3.765625 | 4 | [] | no_license | enum Message {
Quit,
ChangeColor(i32, i32, i32),
Move { x: i32, y: i32 },
Write(String),
}
struct Point{
x:i32,
y:i32,
}
fn main() {
//patterns :matching literals .
let x =1;
let x_str = match x {
1 => "one",
//matching multiple patterns :
2|3 => "two or three",
_ => "above three",
};
println!("x ... | true |
a245023d2b8eefc3d3f92adaa5fe224847774fdb | Rust | juanyavicoli/college | /algorithms/rust/Factorial.rs | UTF-8 | 476 | 3.34375 | 3 | [
"Unlicense"
] | permissive | fn recursive_factorial(n: i64) -> i64 {
if n == 0 {
1
} else {
n * recursive_factorial(n - 1)
}
}
#[test]
fn test_recursive_factorial() {
assert_eq!(recursive_factorial(0), 1);
assert_eq!(recursive_factorial(1), 1);
assert_eq!(recursive_factorial(2), 2);
assert_eq!(recursive... | true |
d0b73d9cf09f0a69bd2c84e58938f8f42f8cea1b | Rust | insanitybit/gsbserver | /src/rice_decoder.rs | UTF-8 | 1,742 | 2.984375 | 3 | [
"MIT"
] | permissive | // Taken from the Golang reference implementation for GSB
use errors::*;
pub struct RiceDecoder<'a> {
br: BitReader<'a>,
k: u32, // Golomb-Rice parameter
}
struct BitReader<'a> {
buf: &'a [u8],
mask: u8,
}
impl<'a> RiceDecoder<'a> {
pub fn new(&mut self, buf: &'a [u8], k: u32) -> RiceDecoder<'a> ... | true |
c8a06410eb454ac310cde917ecf4b5357e44eb23 | Rust | GuilhermoReadonly/ray-tracer | /src/ray.rs | UTF-8 | 3,858 | 3.328125 | 3 | [] | no_license | use crate::{
math::{self, Vec3},
Color, Material, World,
};
// use std::fmt::Debug;
pub struct Ray {
pub origin: Vec3,
pub direction: Vec3,
}
impl Ray {
pub fn new(origin: Vec3, direction: Vec3) -> Self {
Self { origin, direction }
}
pub fn at(self: &Self, t: f64) -> Vec3 {
... | true |
f5a8b73387eb275b2fcb25300b3706196e2e5009 | Rust | adrianchitescu/aoc20-rs | /day14/src/main.rs | UTF-8 | 4,126 | 3.125 | 3 | [] | no_license | extern crate utils;
use std::collections::HashMap;
use utils::utils::*;
trait Instruction {
fn run(&self, c: &mut Computer);
}
struct SetValue {
addr : i64,
value : i64
}
struct SetMask(Vec<(usize, Option<i64>)>);
impl Instruction for SetValue {
fn run(&self, c: &mut Computer) {
// part1
... | true |
8e89f298e11bd3216c5c685479f76a785c8c36b9 | Rust | kakoc/leetcode | /src/swap_overlap.rs | UTF-8 | 2,786 | 3.171875 | 3 | [] | no_license | fn solve(nums: &mut Vec<i32>) {
if nums.len() == 1 {
return;
}
if nums.len() == 2 {
if nums[0] == 0 {
nums[0] = nums[1];
nums[1] = 0;
}
}
let mut swap_start = 0;
let mut swap_end = 0;
for i in 0..nums.len() {
if nums[i] == 0 {
... | true |
0f340c126746109a94379c58f1ea4ce6cc48be1b | Rust | gauteh/ambiq-apollo3-pac | /src/pwrctrl/devpwren/mod.rs | UTF-8 | 44,446 | 2.734375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[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::DEVPWREN {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... | true |
677418927ad9eb268f37c9bea37d127d83d86d36 | Rust | trainman419/msp430fr2433 | /src/port_1_2/p1ies/mod.rs | UTF-8 | 18,934 | 2.875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u8,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u8,
}
impl super::P1IES {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W... | true |
b2a5f36aab4505f5298ce484adcceafb13ca750f | Rust | peterhorne/gba | /src/interrupt_controller.rs | UTF-8 | 2,311 | 3.1875 | 3 | [] | no_license | use bus;
use bit::{Bit, Bits, SetBit};
pub struct InterruptController {
enabled: bool,
asserted: bool,
mask: u16,
flags: u16,
}
#[derive(Clone)]
pub enum Input {
VBlank = 0,
HBlank = 1,
VCounter = 2,
Timer0 = 3,
Timer1 = 4,
Timer2 = 5,
Timer3 = 6,
Serial = 7,
Dma0 =... | true |
542bd03141b3491a912b4d9ab7cd8568241a7c8a | Rust | jpbougie/aoc2020 | /src/bin/06.rs | UTF-8 | 1,184 | 2.90625 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::io::{self, Read};
//use regex::Regex;
use std::collections::HashSet;
use std::collections::HashMap;
fn main() -> io::Result<()> {
let path = env::args().skip(1).next().expect("Specify an input file");
let mut file = File::open(path)?;
let mut s = String::new();
... | true |
33d3025f4e1e6fddf62bf094205feba5b4d8f937 | Rust | collinprince/rust-book | /projects/slice/src/main.rs | UTF-8 | 322 | 3.84375 | 4 | [] | no_license | fn main() {
let s = String::from("Hello, world!");
let copy = first_word(&s);
println!("Copy is: {}", copy);
}
fn first_word(s: &String) -> &str {
let bytes = s.as_bytes();
for (i, &elem) in bytes.iter().enumerate() {
if elem == b' ' {
return &s[..i];
}
}
&s[..]
... | true |
a18435e707cc55f5a4b0ade048b880eda1dbac85 | Rust | ellington-project/tizol | /tests/stft.rs | UTF-8 | 1,642 | 2.921875 | 3 | [] | no_license | use tizol::stft::inplace::STFT as ISTFT;
use tizol::stft::streaming::STFT as SSTFT;
use tizol::stft::WindowType;
#[cfg(test)]
#[test]
fn complete_stft() {
// ten seconds of generated fake audio
let sample_rate: usize = 44100;
let seconds: usize = 10;
let sample_count = sample_rate * seconds;
let al... | true |
3ae4db3d1d574e0fd449b05f1dd639bea80304a4 | Rust | rust-lang/rust | /tests/ui/higher-ranked/subtype/placeholder-pattern-fail.rs | UTF-8 | 577 | 2.84375 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // Check that incorrect higher ranked subtyping
// causes an error.
struct Inv<'a>(fn(&'a ()) -> &'a ());
fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) {
// ok
let _: for<'a> fn(Inv<'a>, Inv<'a>) = f;
let sub: for<'a> fn(Inv<'a>, Inv<'a>) = f;
// no
let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) =... | true |
49808d2d1a141a915ecf6b2ce8b24b3af0deb30e | Rust | taynara-yt/TrabalhoII_Sistema_Embarcados | /Exemplos/exem21.rs | UTF-8 | 586 | 2.984375 | 3 | [
"MIT"
] | permissive | fn main(){
let x:u8 = 128;
let x0:u8 = x >> 0;
let x1:u8 = x >> 1;
let x2:u8 = x >> 2;
let x3:u8 = x >> 3;
let x4:u8 = x >> 4;
let x5:u8 = x >> 5;
let x6:u8 = x >> 6;
let x7:u8 = x >> 7;
//Reproduzindo exemplo do slide 34
println!("Operadores de Deslocamento\n"... | true |
5a4d09d2bc2f77b2361d91d0e267afeb05be121c | Rust | Jasleen1/zkinterface | /rust/src/consumers/workspace.rs | UTF-8 | 4,941 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::path::{PathBuf, Path};
use std::fs::{File, read_dir};
use std::iter;
use std::io::{Read, stdin};
use std::ffi::OsStr;
use crate::consumers::reader::read_buffer;
use crate::{Result, Message, Messages};
/// Workspace finds and reads zkInterface messages from a directory.
/// It supports reading messages one-by... | true |
186ec272154fc265fabcbd64d90c2fce1d77b9f9 | Rust | roysc/quadtree-rs | /main.rs | UTF-8 | 1,419 | 2.640625 | 3 | [] | no_license | #![feature(slicing_syntax)]
// #![feature(phase)]
// #[phase(plugin, link)] extern crate log;
use std::time;
mod quadtree;
// TODO make time work...
fn now() -> u64 { time::precise_time_ns() }
macro_rules! benchmark(
($what: expr) => {
{
let start_time = now();
let ret = ... | true |
a93fea498d85fd49718a882a18bfc918d0dea318 | Rust | vandenheuvel/chalk | /chalk-solve/src/display/ty.rs | UTF-8 | 12,267 | 2.640625 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"bzip2-1.0.6",
"LicenseRef-scancode-other-permissive",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"Unlicense"
] | permissive | //! Writer logic for types.
//!
//! Contains the highly-recursive logic for writing `TyData` and its variants.
use std::fmt::{Formatter, Result};
use crate::split::Split;
use chalk_ir::{interner::Interner, *};
use itertools::Itertools;
use super::{
display_self_where_clauses_as_bounds, display_type_with_generics,... | true |
297757ade05941c6f1ddede4d896e2e7994c73e0 | Rust | Medi-medication-reminder-app/medi-backend | /src/models/database/treatment.rs | UTF-8 | 2,514 | 2.765625 | 3 | [] | no_license | use diesel::mysql::MysqlConnection;
use diesel::prelude::*;
use diesel::result::Error;
use crate::schema::treatments;
#[derive(Serialize, Deserialize, Queryable, Insertable, AsChangeset)]
#[table_name = "treatments"]
pub struct Treatment {
pub treatment_id: Option<i32>,
pub user_id: i32,
pub name: String... | true |
b6522fc644bc57d9fce64b8c273502dae7580c72 | Rust | diglyt/nock | /src/main.rs | UTF-8 | 13,157 | 3.296875 | 3 | [] | no_license | //! Urbit Nock 4K data structures, with basic parsing, and evaluation.
//! <https://urbit.org/docs/learn/arvo/nock/>
#![feature(never_type, exact_size_is_empty)]
use byteorder::{ByteOrder, LittleEndian};
use derive_more::Constructor;
use env_logger;
use log::{debug, error, info, log, trace, warn};
use std::{clone::Clon... | true |
4a004339c3600879a90771836fb77cee17f446d7 | Rust | moroso/compiler | /src/codegen/mod.rs | UTF-8 | 1,340 | 2.546875 | 3 | [] | no_license | use mas::ast::Reg;
pub use codegen::ir_to_asm::IrToAsm;
pub use self::RegisterColor::*;
pub mod register_color;
pub mod ir_to_asm;
pub mod combine;
/// How many variables are available to the register allocator.
pub static NUM_USABLE_VARS: usize = 30;
// Special registers.
pub static LINK_REGISTER: Reg = Reg { inde... | true |
4d3a8614e3d5d396d34a97927690faaadaa84ea6 | Rust | jtdowney/advent-2020 | /src/day12.rs | UTF-8 | 4,090 | 3.65625 | 4 | [] | no_license | use std::{num::ParseIntError, ops::Add, str::FromStr};
#[derive(Copy, Clone)]
enum Action {
North,
South,
East,
West,
Left,
Right,
Forward,
}
impl FromStr for Action {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let instruction = match s {
... | true |
84c053be25e7873c6380a9f2dfa159018483250f | Rust | tyrylu/feel-the-streets | /server/src/diff_utils.rs | UTF-8 | 3,798 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::Result;
use base64::prelude::*;
use osm_db::entity::Entity;
use osm_db::semantic_change::EntryChange;
use serde_json::{Map, Value};
use std::{collections::HashSet, hash::Hash};
pub enum ListChange<T> {
Add(T),
Remove(T),
}
fn diff_properties(old: &Entity, new: &Entity) -> Vec<EntryChange> {
let... | true |
ce3646010e51c79143af20241fbc21b9966e64f4 | Rust | FMRb/adventOfCode20 | /day16/src/main.rs | UTF-8 | 5,039 | 3.375 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::env;
use std::fs;
use std::str::Lines;
fn main() -> Result<(), Box<dyn (std::error::Error)>> {
let args: Vec<String> = env::args().collect();
if args.len() != 2 {
println!("Usage: <path_to_input>");
std::process::exit(1);
}
println!("Argument {}"... | true |
5fa6dc010565b6a7a9a3c9e6f31a48cb44864f8f | Rust | Doslin/gomoku | /backend/src/main.rs | UTF-8 | 2,828 | 2.59375 | 3 | [] | no_license | use clap::clap_app;
use std::env;
mod minimax;
mod board;
mod control;
mod monte;
#[cfg(feature = "server")]
mod server;
mod utils;
mod algo;
fn main() {
let matches = clap_app!(myapp =>
(version: "0.1")
(author: "yukang <moorekang@gmail.com>")
(about: "Algo backend for Gomoku")
(@a... | true |
0328c1c8af39b75db72273f2818d74fc14168739 | Rust | triscuitcircuit/projecta1tactics | /src/backend/tactics_audio.rs | UTF-8 | 2,642 | 2.65625 | 3 | [] | no_license | use bevy_kira_audio::{Audio, AudioChannel, AudioPlugin, AudioSource};
use bevy_inspector_egui::InspectorPlugin;
use std::collections::HashMap;
use bevy::prelude::*;
use bevy::asset::LoadState;
// Sample code from Kira_audio github
pub struct AudioState{
audio_loaded: bool,
loop_handle: Handle<AudioSource>,
... | true |
fa27b01436ee6fc8391f95978716681d175854da | Rust | makotokato/gecko-dev | /third_party/rust/wgpu-core/src/assertions.rs | UTF-8 | 1,348 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! Macros for validation internal to the resource tracker.
//!
//! This module defines assertion macros that respect `wgpu-core`'s
//! `"strict_asserts"` feature.
//!
//! Because `wgpu-core`'s public APIs validate their arguments in all
//! types of builds, for performance, the `track` module skips some of
//! Rust's ... | true |
f76e7fdec943899317729ddad1af57382b06e53f | Rust | eminence/prom_weather_server | /src/NWS.rs | UTF-8 | 2,316 | 3.078125 | 3 | [] | no_license | //! Structs for the National Weather Service API
use ::{UpdatableWeatherData, get_json_from_url};
use ::units::*;
use ::time;
#[derive(Debug, Deserialize)]
#[allow(non_snake_case)]
pub struct NWSData {
pub properties: NWSDataInner
}
#[derive(Debug, Deserialize)]
#[allow(non_snake_case)]
pub struct NWSDataInner {
... | true |
941959021a4e02fb755a542b11555614d413bc0e | Rust | rob-brown/AdventOfCode2019 | /src/aoc/day5.rs | UTF-8 | 525 | 2.625 | 3 | [
"MIT"
] | permissive | use super::assert::*;
use super::intcode::Machine;
pub fn solve() {
let initial = Machine::from_file("input/day5.txt");
let mut machine = Machine::init(&initial.positions);
machine.run(vec![1]);
assert_eq(
Day::new(5, Part::A),
11_049_715,
machine.values.pop_back().unwrap(),
... | true |
e1db37dc476204c723a3176b9455174cdadea45a | Rust | wirehell/advent-of-code-2019 | /src/bin/day19.rs | UTF-8 | 3,915 | 2.890625 | 3 | [] | no_license | use std::{env, thread};
use advent_of_code_2019::intmachine;
use std::cell::RefCell;
use std::rc::Rc;
use std::collections::{HashMap, VecDeque};
use std::sync::mpsc::{SyncSender, Receiver};
use advent_of_code_2019::intmachine::{Message, Word, execute_with_result, Memory};
use std::sync::mpsc;
use std::borrow::Borrow;
u... | true |
3054e948a1e39e0a434e3b2e349d1bfec9e9f2cb | Rust | Centril/jellyschema | /src/schema/type.rs | UTF-8 | 8,361 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | use std::{fmt, str::FromStr};
use crate::error::Error;
const OBJECT_KEYWORD: &str = "object";
const BOOLEAN_KEYWORD: &str = "boolean";
const STRING_KEYWORD: &str = "string";
const PASSWORD_KEYWORD: &str = "password";
const HOSTNAME_KEYWORD: &str = "hostname";
const INTEGER_KEYWORD: &str = "integer";
const ARRAY_KEYWO... | true |
c166ebfbfdaed511b6b2855dfadaee782e11a29d | Rust | berkus/liquid-rust | /src/interpreter/variable.rs | UTF-8 | 3,305 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::fmt;
use itertools;
use error::Result;
use value::Index;
use super::Context;
use super::Renderable;
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Variable {
indexes: Vec<Index>,
}
impl Variable {
pub fn new<I: Into<Index>>(value: I) -> Self {
let indexes = vec![value.into()];
... | true |
106439b6bc366c47caaa193740b70bd2816683d0 | Rust | rohitjoshi/irc | /src/conn.rs | UTF-8 | 10,824 | 2.875 | 3 | [
"Unlicense",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-public-domain"
] | permissive | //! Thread-safe connections on IrcStreams.
#![experimental]
use std::sync::{Mutex, MutexGuard};
use std::io::{BufferedReader, BufferedWriter, IoResult, TcpStream};
#[cfg(any(feature = "encode", feature = "ssl"))] use std::io::{IoError, IoErrorKind};
#[cfg(feature = "encode")] use encoding::{DecoderTrap, EncoderTrap, En... | true |
69bbc89065bd40254d60dd14b5659fd16909190e | Rust | Global19/slack-notification-resource | /src/concourse/out/args.rs | UTF-8 | 8,061 | 2.5625 | 3 | [] | no_license | use std::env;
use std::fmt::Debug;
use std::result::Result as StdResult;
use std::path::PathBuf;
use structopt::StructOpt;
use failure::Error;
use error::*;
use io::*;
use core::*;
use util::*;
use concourse::*;
use concourse::out::request::*;
use concourse::out::validator::*;
// @todo field scope
#[derive(StructOpt,... | true |
d51b1e5256f3f57e1f5ebc8fefd47fc2c549c19b | Rust | Yurihaia/xivc | /src/math/data.rs | UTF-8 | 3,242 | 2.78125 | 3 | [] | no_license | use xivc_macros::embed_data;
use crate::{Clan, Job};
pub const fn attack_power(job: Job) -> JobField {
use Job::*;
match job {
ROG | NIN | ARC | BRD | MCH | DNC => JobField::DEX,
_ => JobField::STR,
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
// This is the naming conventions used a... | true |
452802661ef3d71b7447202b3d193124adb28c2d | Rust | kas-gui/kas | /crates/kas-core/src/popup.rs | UTF-8 | 4,741 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | // 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 in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! Popup root
use crate::dir::Direction;
use crate::event... | true |
57f43ac811f9c7d036679a79dc4682c69264da29 | Rust | Serentty/rusty-dos | /src/port.rs | UTF-8 | 1,018 | 2.796875 | 3 | [] | no_license | #![allow(unused_assignments)]
use core::arch::asm;
#[inline(always)]
pub unsafe fn inb(port: u16) -> u8 {
let value;
asm!(
"in al, dx",
in("dx") port,
out("al") value,
);
value
}
#[inline(always)]
pub unsafe fn inw(port: u16) -> u16 {
let value;
asm!(
"in ax, d... | true |
3cc86bd3dbf619b54fb325d043cc68c8bfb4b666 | Rust | ankit-mogha/KUP_Rust | /assignments/assignment_twelve/src/async_await/tables_asynchronously.rs | UTF-8 | 708 | 3.09375 | 3 | [] | no_license | use async_std::task;
use std::time::Duration;
/// async_print_tables function simultaneously print two table of 2 amd 3 in asynchronous manner.
///
/// #Arguments
///
/// No Arguments.
///
/// #Return
///
/// No return value.
pub async fn async_print_tables() {
env_logger::init();
let table_of_2 = async {
... | true |
bd1e973e71c2100a7a36993219daeaaccd62dacf | Rust | Escapingbug/cmu-15-411-lab | /lab1/src/parser/ast.rs | UTF-8 | 1,871 | 3.140625 | 3 | [] | no_license | #[derive(Debug, Clone)]
pub enum AstNode {
Stmt(Stmt),
Decl(Decl),
Lvalue(Lvalue),
Expr(Expr),
Binop(Binop),
Asnop(Asnop),
}
#[derive(Debug, Clone)]
pub enum Stmt {
/// Decl(Decl)
Decl(Box<AstNode>),
/// Simp(Lvalue, Asnop, Expr)
Simp(Box<AstNode>, Box<AstNode>, Box<AstNode>),
... | true |
0bbccbd3f74f579fdeb2034c5d663233cc5ec21b | Rust | drbrain/AOC | /2020/src/bin/day_1.rs | UTF-8 | 1,028 | 3.21875 | 3 | [] | no_license | use anyhow::Result;
use aoc2020::read;
use itertools::Itertools;
fn main() -> Result<()> {
let input = read("./01.input")?;
println!("part A: {}", day_1(&input, 2)?);
println!("part B: {}", day_1(&input, 3)?);
Ok(())
}
fn day_1(input: &str, entries: usize) -> Result<u32> {
let numbers: Vec<u32... | true |
1ec3654c43341cb0644a856becb37b752b5a2b8c | Rust | FIL1994/Rust_WASM_types | /src/wasm_num.rs | UTF-8 | 818 | 3.03125 | 3 | [] | no_license | use std::sync::Mutex;
use wasm_rand::ComplementaryMultiplyWithCarryGen;
struct Random {
pub rand: ComplementaryMultiplyWithCarryGen
}
impl Random {
pub fn new() -> Random {
Random {
rand: ComplementaryMultiplyWithCarryGen::new(1)
}
}
pub fn get_num(&mut self) -> u32 {
... | true |
72556d83a0c767d056936a1bd1a4e2aa322b927f | Rust | XuShaohua/nc | /src/calls/setfsuid.rs | UTF-8 | 381 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | /// Set user identify used for filesystem checkes.
///
/// # Example
///
/// ```
/// let ret = unsafe { nc::setfsuid(0) };
/// assert!(ret.is_ok());
/// let uid = unsafe { nc::getuid() };
/// assert_eq!(ret, Ok(uid));
/// ```
pub unsafe fn setfsuid(fsuid: uid_t) -> Result<uid_t, Errno> {
let fsuid = fsuid as usize;... | true |
fb4e9773053733cf43c18ac7e7297bfb1b664ad5 | Rust | seeseemelk/gpg-tui | /src/app/command.rs | UTF-8 | 17,382 | 3.0625 | 3 | [
"MIT"
] | permissive | use crate::app::mode::Mode;
use crate::app::prompt::OutputType;
use crate::app::selection::Selection;
use crate::app::style::Style;
use crate::gpg::key::KeyType;
use crate::widget::row::ScrollDirection;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::str::FromStr;
/// Command to run on rendering proc... | true |
92948c5c43fba09f1e519eaa5b6e58e39b8bbec7 | Rust | konamilk/atcoder-abc165 | /src/bin/d.rs | UTF-8 | 745 | 3 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::source::auto::AutoSource;
#[allow(unused_imports)]
use proconio::marker::{Chars, Bytes};
#[allow(unused_imports)]
use num::integer::{sqrt, gcd, lcm};
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
fn main() {
// let source = AutoSource::from(... | true |
25c263ca0c071188d80a0834ffbcd9c96e537230 | Rust | llewekam/ErrorHandlingRust | /src/main.rs | UTF-8 | 345 | 2.828125 | 3 | [] | no_license | extern crate error_handling;
use std::env;
use error_handling::token;
fn main() {
let token_string = command_line_token();
token::do_token_stuff(&token_string);
println!("{}", token_string);
}
fn command_line_token() -> String {
if let Some(arg) = env::args().nth(1) {
return arg;
}
... | true |
a5ad6498b3df081701e6983dfb0db54f6f994ec4 | Rust | yangzhe1990/conflux-rust | /core/src/evm/evm.rs | UTF-8 | 6,534 | 2.78125 | 3 | [
"GPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.0-or-later",
"GPL-3.0-or-later",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-copyleft"
] | permissive | // Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | true |
17c7f574d49b51de46d79679e3c9fa5b31a4d1e2 | Rust | BurntSushi/blog | /code/transducers/src/bin/query-map-get.rs | UTF-8 | 959 | 2.953125 | 3 | [
"MIT",
"Unlicense"
] | permissive | #![allow(dead_code, unused_imports, unused_macros, unused_variables)]
extern crate fst;
extern crate fst_levenshtein;
extern crate fst_regex;
use std::error::Error;
fn main2() -> Result<(), Box<Error+Send+Sync>> {
use fst::Map;
let map = Map::from_iter(vec![
("bruce", 1972),
("clarence", 1972),
(... | true |
16a5b36dad70d5741db7224a788bf4a8ebb7bd4f | Rust | RoaringBitmap/roaring-rs | /tests/lib.rs | UTF-8 | 3,723 | 3.3125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate roaring;
use roaring::RoaringBitmap;
#[test]
fn smoke() {
let mut bitmap = RoaringBitmap::new();
assert_eq!(bitmap.len(), 0);
assert!(bitmap.is_empty());
bitmap.remove(0);
assert_eq!(bitmap.len(), 0);
assert!(bitmap.is_empty());
bitmap.insert(1);
assert!(bitmap.contains(1))... | true |
6e2d565638bfb22d0eb6f8005336a0007cd338cd | Rust | fizyk20/atm-raytracer | /src/coloring/shading.rs | UTF-8 | 2,239 | 2.90625 | 3 | [] | no_license | use super::ColoringMethod;
use crate::generator::{PixelColor, TracePoint};
use image::Rgb;
use nalgebra::Vector3;
#[derive(Debug, Clone, Copy)]
pub struct Shading {
water_level: f64,
ambient_light: f64,
light_dir: Vector3<f64>,
}
impl Shading {
pub fn new(water_level: f64, ambient_light: f64, light_... | true |
609bdad7af450d7ea8f5294388be2a73b4bad188 | Rust | acidburn0zzz/ruffle | /core/src/xml/error.rs | UTF-8 | 2,871 | 2.921875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Error types used in XML handling
use gc_arena::{Collect, CollectionContext};
use quick_xml::Error as QXError;
use std::error::Error as StdError;
use std::fmt::Error as FmtError;
use std::fmt::{Display, Formatter};
use std::rc::Rc;
use std::str::Utf8Error;
use std::string::FromUtf8Error;
use thiserror::Error;
#[de... | true |
5ea36644aeea83dde6d2bf94ccf8d533f8d015e5 | Rust | iyzana/advent-of-code-2019 | /src/day3.rs | UTF-8 | 2,846 | 3.46875 | 3 | [] | no_license | use std::collections::HashSet;
#[aoc_generator(day3)]
fn parse(input: &str) -> (Wire, Wire) {
let mut lines = input.lines();
(
Wire::from(lines.next().unwrap()),
Wire::from(lines.next().unwrap()),
)
}
#[derive(Debug)]
struct Wire {
points: Vec<(i32, i32)>,
}
impl From<&str> for Wire {... | true |
b22fa95ff99af92c84679e2fc63a3f2a1527de86 | Rust | eupn/bno055 | /examples/calibrate.rs | UTF-8 | 2,467 | 2.9375 | 3 | [
"MIT"
] | permissive | use bno055::{BNO055OperationMode, Bno055};
use linux_embedded_hal::{Delay, I2cdev};
use mint::{EulerAngles, Quaternion};
fn main() {
let dev = I2cdev::new("/dev/i2c-0").unwrap();
let mut delay = Delay {};
let mut imu = Bno055::new(dev).with_alternative_address();
imu.init(&mut delay).expect("An error o... | true |
51092c950857007f69abac004cf0b87f7f23bcb7 | Rust | allenap/rust-petname | /src/lib.rs | UTF-8 | 18,123 | 3.4375 | 3 | [
"Apache-2.0"
] | permissive | #![no_std]
//!
//! You can populate [`Petnames`] with your own word lists, but the word lists
//! from upstream [petname](https://github.com/dustinkirkland/petname) are
//! included with the `default_dictionary` feature (enabled by default). See
//! [`Petnames::small`], [`Petnames::medium`], and [`Petnames::large`] to ... | true |
185af9d5e21cc1c328fa214e22a8060cccc821eb | Rust | jerincoded/rust | /projects/guessing_game/src/main.rs | UTF-8 | 320 | 3.34375 | 3 | [] | no_license | use std::io; //Including a headerfile
//Main function
fn main() {
println!("Hello, world!");
println!("Guess Name!");
println!("Please input your guess. ");
let mut guess = String::new();
io::stdin().read_line(& mut guess).expect("Failed to readline");
println!("Your Guess {}",guess);
}
| true |
c14fb815130bac9fe45d38ca2ade821ed710850e | Rust | isgasho/galangua | /mods/galangua-common/src/app/game/appearance_table.rs | UTF-8 | 3,129 | 2.5625 | 3 | [
"MIT"
] | permissive | use counted_array::counted_array;
use crate::app::game::traj_command::TrajCommand;
use crate::app::game::traj_command_table::*;
use crate::app::game::{EnemyType, FormationIndex};
const fn p(x: u8, y: u8) -> FormationIndex { FormationIndex(x, y) }
pub const ORDER: [FormationIndex; 40] = [
p(4, 2), p(5, 2), p(4, 3... | true |
d5d8f34f14c6c1a064d74862aa40e820ddf0c03f | Rust | magurotuna/atcoder-submissions | /abc131/src/bin/c.rs | UTF-8 | 1,437 | 3.34375 | 3 | [] | no_license | use libprocon::*;
fn main() {
input! {
a: usize,
b: usize,
c: usize,
d: usize,
}
// a以上b以下の整数は a-b+1 個
// そのうち、cの倍数であるもの、dの倍数であるもの、LCM(c, d)の倍数であるもの、の個数を求めて、
// いい感じに集合の演算をすればおk
let cc = count(a, b, c);
let dd = count(a, b, d);
let ccdd = count(a, b, lcm... | true |
ef559a4aef8c68cf852fcd65c784af50499c1cbe | Rust | leshow/pulsar-rs | /src/executor.rs | UTF-8 | 1,115 | 2.734375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use futures::future::{ExecuteError, Executor, Future};
use std::sync::Arc;
pub trait PulsarExecutor: Executor<BoxSendFuture> + Send + Sync + 'static {}
impl<T: Executor<BoxSendFuture> + Send + Sync + 'static> PulsarExecutor for T {}
type BoxSendFuture = Box<dyn Future<Item = (), Error = ()> + Send + 'static>;
#[der... | true |
f57c45acafccace4f675d9291c0f31b313f76baf | Rust | imorph/vector | /lib/vrl/stdlib/src/to_regex.rs | UTF-8 | 1,981 | 2.96875 | 3 | [
"MPL-2.0"
] | permissive | use tracing::warn;
use vrl::prelude::*;
#[derive(Clone, Copy, Debug)]
pub struct ToRegex;
impl Function for ToRegex {
fn identifier(&self) -> &'static str {
"to_regex"
}
fn parameters(&self) -> &'static [Parameter] {
&[Parameter {
keyword: "value",
kind: kind::BYTE... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.