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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3cc573cf2eced240871c8e24e00fad78e5afe3d4 | Rust | denysvitali/aoc-2020 | /days/dec18/src/test.rs | UTF-8 | 446 | 2.5625 | 3 | [
"MIT"
] | permissive | mod test {
use crate::{solve_puzzle, evaluate_expr};
use utils::get_file;
#[test]
fn example(){
let f = get_file(file!(), "1.txt");
assert_eq!(26 + 437 + 12240 + 13632, solve_puzzle(f.as_str()).unwrap());
}
#[test]
fn expr_0(){
assert_eq!(51, evaluate_expr("1 + (2 *... | true |
d4cb420667648607b4e5131685104960132f1a58 | Rust | isso0424/vc_time_keeper | /src/discord/client.rs | UTF-8 | 2,283 | 2.75 | 3 | [] | no_license | use crate::discord::action::kick;
use crate::timer::event_loop::lazy_event;
use chrono::offset::Local;
use chrono::{Datelike, Duration, NaiveTime, TimeZone};
use serenity::framework::standard::macros::{command, group};
use serenity::framework::standard::{CommandResult, StandardFramework};
use serenity::model::prelude::... | true |
41cc5b7e32fe10ec5018c73a9fcdc2172ab0fb40 | Rust | benrady/rust-tdd-katas | /fizzbuzz/src/fizzlib.rs | UTF-8 | 323 | 3.578125 | 4 | [
"Unlicense"
] | permissive | use std::string::String;
pub fn fizzbuzz(number: &int) -> String{
if *number % 15 == 0 {
String::from_str("fizzbuzz")
}
else if *number % 3 == 0 {
String::from_str("fizz")
}
else if *number % 5 == 0 {
String::from_str("buzz")
}
else {
number.to_string()
}... | true |
20d58d3d6fb962c3d3f4eeca38ce4e53b98d1c5f | Rust | theseus-os/Theseus | /tools/serialize_nano_core/src/main.rs | UTF-8 | 1,014 | 2.515625 | 3 | [
"MIT"
] | permissive | //! Tool that creates a serialized representation of the symbols in the `nano_core` binary.
mod parse;
use crate_metadata_serde::SerializedCrate;
use std::io::Write;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let path = &std::env::args().nth(1).expect("no path provided");
let symbol_file = std::fs... | true |
11d070c3c3f36c942c702ead591c6a1888ed6d50 | Rust | pwoolcoc/zmq-tokio | /zmq-mio/src/lib.rs | UTF-8 | 14,847 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Asynchronous `ØMQ`, a.k.a.`(ZeroMQ)` in `Rust` with `mio`.
//!
//! Run ØMQ sockets that implement `mio::Evented`, as well as non-blocking
//! implementations of `io::Write` and `io::Read`.
//!
//! # Example
//!
//! ```
//! extern crate mio;
//! extern crate zmq;
//! extern crate zmq_mio;
//!
//! use std::io;
//! us... | true |
4116a3204c8a5727dc57c55906315572f77acdee | Rust | bpglaser/advent | /2021/day02_part01/src/main.rs | UTF-8 | 767 | 3.171875 | 3 | [] | no_license | use std::env::args;
use std::error::Error;
use std::fs::read_to_string;
use std::panic;
fn main() -> Result<(), Box<dyn Error>> {
let path = args().skip(1).next().ok_or("not enough args")?;
let content = read_to_string(&path)?;
let (x, y) = content.lines().map(parse_line).fold((0, 0), do_move);
println... | true |
d91af54ea4f41316b8b76b09527bb4d1ae34505c | Rust | rlebre/dicom-rs | /object/src/lib.rs | UTF-8 | 3,836 | 3.203125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! This crate contains a high-level abstraction for reading and manipulating
//! DICOM objects.
//! At this level, objects are comparable to a dictionary of elements,
//! in which some of them can have DICOM objects themselves.
//! The end user should prefer using this abstraction when dealing with DICOM
//! objects.
... | true |
9a5200333caaee064807b295ed4565cd27f97fbd | Rust | inda20plusplus/hansing-chess | /hansing-chess/src/square.rs | UTF-8 | 1,733 | 3.453125 | 3 | [] | no_license | use std::fmt;
#[derive(Eq, PartialEq, Hash, Debug, Clone, Copy)]
pub struct Square(i32, i32);
impl Square {
pub fn is_in_bounds(&self) -> bool {
self.0 >= 0 && self.0 < 8 && self.1 >= 0 && self.1 < 8
}
pub fn offset(&self, rank_offset: i32, file_offset: i32) -> Option<Self> {
let s = Self(s... | true |
732d7680262e7c225a75265aad7743f1ad18c11e | Rust | ackintosh/sandbox | /rust/threading/src/thread_pool.rs | UTF-8 | 1,590 | 2.828125 | 3 | [] | no_license | use futures::executor::block_on;
use futures::task::SpawnExt;
use futures::FutureExt;
// https://crates.io/crates/futures
// M:Nモデルのスレッドプール
#[test]
fn test() {
handle();
// TODO
// tx_rx();
}
// //////////////////////////////////////////////////////////
// handleを使ってスレッドの処理が終わるのを待つパターン
// ////////////////... | true |
4cfd50409d6dde727ff54dd78657135d79eaa693 | Rust | truchi/lay | /src/style/gen/attributes/overline.rs | UTF-8 | 903 | 2.921875 | 3 | [] | no_license | ////////////////////////////////////////////////////////////////////////////////
// 🚨🚨🚨🚨🚨🚨🚨🚨 This file is @generated by build script. 🚨🚨🚨🚨🚨🚨🚨🚨 //
// 🚧🚧🚧🚧🚧🚧🚧🚧 ⛔ DO NOT MODIFY! ⛔ 🚧🚧🚧🚧🚧🚧🚧🚧 //
///////////////////////////////////////////////////////////////////////////////... | true |
fe669735c715fecddeefbd8fd6b0a15bd6c10c5a | Rust | ktalmadge/wasm-tracer | /src/ray_tracer/tone/mod.rs | UTF-8 | 867 | 2.921875 | 3 | [] | no_license | use super::color::Color;
// e ^ (1/n SUM( ln( luminance[x][y] + delta ) ) )
pub fn log_average_luminance(
color_buffer: &mut Vec<Vec<Color>>,
width: usize,
height: usize,
delta: f64,
) -> f64 {
let mut sum: f64 = 0f64;
for x in 0..width {
for y in 0..height {
sum += (color_b... | true |
a0fa47f3d6e838adf70a279dd1648d8dc874c291 | Rust | amarant/hackerrank-rust | /src/algorithms/warmup/extra_long_factorials.rs | UTF-8 | 464 | 3.109375 | 3 | [
"MIT"
] | permissive | extern crate num;
use std::io;
use std::io::BufRead;
use num::bigint::{BigUint, ToBigUint};
use num::One;
fn big_factorial(n: usize) -> BigUint {
if n == 0 {
return One::one();
}
n.to_biguint().unwrap() * big_factorial(n - 1)
}
fn main() {
let stdin = io::stdin();
let line = stdin.lock().... | true |
73c1a527fde75011444497037ab7e6277ffc8566 | Rust | yutopp/yterm | /yterm_backend/src/terminal.rs | UTF-8 | 4,507 | 2.625 | 3 | [] | no_license | use std::ffi::CString;
use std::os::unix::io::AsRawFd;
use std::sync::Arc;
use crate::pty;
use crate::state::Shared;
use crate::window;
#[derive(Debug)]
pub enum Event {
Terminal(Vec<u8>),
}
pub struct Terminal {
master: pty::Master,
slave: pty::Slave,
shared: Shared,
state: State,
}
pub struct... | true |
75b995dc9e54cd01393e35295f7a49884147057e | Rust | rustkas/rust-by-example-imp | /rust-by-example/fn_/src/capture3.rs | UTF-8 | 542 | 2.859375 | 3 | [
"MIT"
] | permissive | // cargo run -p fn_ --bin capture3
fn do_twice<F>(mut func: F)
where F: FnMut()
{
for _i in 0..=100 {
func();
}
// func();
// func();
}
fn main() {
let mut x: usize = 1;
{
let add_two_to_x = || x += 2;
do_twice(add_two_to_x);
// do_twice(add_two_to_x);
}
l... | true |
2881444f5ef8221d22d7d089f8a8be7a4e2f453b | Rust | Rahix/ws2812-spi-rs | /src/lib.rs | UTF-8 | 2,682 | 3 | 3 | [] | no_license | #![no_std]
extern crate embedded_hal as hal;
use hal::spi::{FullDuplex, Mode, Phase, Polarity};
use nb;
use nb::block;
/// SPI mode
pub const MODE: Mode = Mode {
polarity: Polarity::IdleLow,
phase: Phase::CaptureOnFirstTransition,
};
pub struct Ws2812<SPI> {
spi: SPI,
}
/// RGB
pub type Color = (u8, u... | true |
7b2511610617e254f32594f8c687047ea5f1b340 | Rust | marc47marc47/leetcode-cn | /63unique-paths-ii/uniquepath/src/main.rs | UTF-8 | 975 | 2.984375 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
}
pub struct Solution {}
impl Solution {
pub fn unique_paths_with_obstacles(obstacle_grid: Vec<Vec<i32>>) -> i32 {
let rows = obstacle_grid.len();
if rows == 0 {
return 0
}
let cols = obstacle_grid[0].len();
if cols == 0 {
... | true |
8450c0cb500e5212f5149b438de36f3a1978b602 | Rust | Fantom-foundation/libnode-membership | /src/hash.rs | UTF-8 | 1,371 | 3.1875 | 3 | [
"MIT"
] | permissive | use bincode;
use failure::Fail;
use serde::{Deserialize, Serialize};
use sha3::{digest::generic_array::transmute, Digest, Sha3_256};
/// Type of hash commonly used within the library.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Hash(pub [u8; 32]);
/// Hashing errors.
#[d... | true |
3d2e48407b3706992376b6b938a1e53ab8aadc4e | Rust | amol9/matasano | /src/set2/cbcadmin.rs | UTF-8 | 3,281 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use common::{err, challenge, hex, ascii};
use common::cipher::{aes, key};
pub static info: challenge::Info = challenge::Info {
no: 16,
title: "CBC bitflipping attacks",
help: "",
execute_fn: interactive
};
const escape_chars: [char; 3] = [';', '=', ... | true |
dd6c0dd9978876e470d7ecb1511254984cd2e0e7 | Rust | KilianVounckx/rt1w | /src/material/metal.rs | UTF-8 | 867 | 2.78125 | 3 | [] | no_license | use rand::rngs::ThreadRng;
use super::Material;
use crate::ray::Ray;
use crate::shape::HitRecord;
use crate::vec3::{Color, Vec3};
pub struct Metal {
color: Color,
fuzz: f64,
}
impl Metal {
pub fn new(color: Color, fuzz: f64) -> Self {
Self { color, fuzz }
}
}
impl Default for Metal {
fn ... | true |
d5493059ea3c80acd09652b2ce38a29b306bff38 | Rust | cpralea/xlang | /xlc/src/main.rs | UTF-8 | 4,791 | 2.734375 | 3 | [
"MIT"
] | permissive | extern crate argparse;
extern crate itertools;
#[macro_use]
extern crate maplit;
extern crate ref_eq;
mod common;
mod analyzer;
mod ast;
mod cdata;
mod config;
mod dumper;
mod emitter;
#[macro_use]
mod io;
mod parser;
mod tokenizer;
use std::process;
fn main() {
let config = parse_cmd_line();
let source =... | true |
69842c0302c27a5d455be2875e5a8f15ec6395fa | Rust | Ethan826/connect-four | /src/game.rs | UTF-8 | 5,383 | 3.546875 | 4 | [] | no_license | use super::{Dimensions, GameError, Space};
use std::fmt;
#[derive(Debug)]
pub struct Game {
state: Vec<Vec<Space>>,
number_for_win: usize,
dimensions: Dimensions,
}
#[derive(Debug, Copy, Clone)]
pub enum Player {
AI,
Opponent,
}
#[derive(Debug, Copy, Clone)]
struct RunData {
ai: usize,
op... | true |
e52efbf9771f412929bed966716faf658151cdb1 | Rust | rico22/ev3dev-lang-rs | /src/device.rs | UTF-8 | 7,491 | 2.609375 | 3 | [] | no_license | use std::collections::HashSet;
use std::collections::HashMap;
use std::fs;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::Read;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use std::ops::Deref;
use std::io::{Result, Error, ErrorKind};
pub type Matches = HashSet<String>;
pub type Attribut... | true |
b9eae47a492f15479007a2302712f9e480a7fba6 | Rust | aviansie-ben/yet-another-static-java-compiler | /compiler/src/mil/il/known_objects.rs | UTF-8 | 1,470 | 2.515625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::resolve::ClassId;
use crate::static_heap::JavaStaticRef;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MilKnownObjectId(pub u32);
#[derive(Debug, Clone)]
pub struct MilKnownObjectRefs {
pub classes: HashMap<ClassId, MilKnownObjectId>,
pub strings: Vec... | true |
04a162de08821338f806ec03c8dc31ec9d9711f2 | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/foreign/foreign-fn-with-byval.rs | UTF-8 | 635 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
#![allow(improper_ctypes)]
// ignore-wasm32-bare no libc to test ffi with
#[derive(Copy, Clone)]
pub struct S {
x: u64,
y: u64,
z: u64,
}
#[link(name = "rust_test_helpers", kind = "static")]
extern {
pub fn get_x(x: S) -> u64;
pub fn get_y(x: S) -> u64;
pub fn get_z(x: S) -> u64;
... | true |
3c0359d2ef758742947322d1f1182bf21b69dd70 | Rust | TOETOE55/gen-rs | /src/impls/helper.rs | UTF-8 | 544 | 2.515625 | 3 | [] | no_license | use crate::Gen;
use std::pin::Pin;
pub struct Resume<'a, 'b, Send, Recv> {
gen: Pin<&'a mut Gen<'b, Send, Recv>>,
}
impl<'a, 'b, Send, Recv> Resume<'a, 'b, Send, Recv> {
pub fn new(gen: Pin<&'a mut Gen<'b, Send, Recv>>) -> Self {
Self { gen }
}
pub fn resume(&mut self, send: Send) -> Option<R... | true |
350ad15ca0221f1cc44d9b39a1d067ec9b2ba184 | Rust | cyclopunk/labyrinth-brew-game | /crates/lab-entities/src/player.rs | UTF-8 | 2,538 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive |
use bevy::{ prelude::* };
use lab_core::prelude::*;
use std::time::Duration;
#[derive(Clone, Copy, Debug, Properties)]
pub struct Player {
pub god_mode : bool
}
impl Default for Player {
fn default() -> Player {
Player {
god_mode: false
}
}
}
#[derive(Debug, Bundle)]
pub s... | true |
5b830f5aea474b6013e1ec9610db57e687cb64a8 | Rust | Buzzec/concurrency_traits | /src/mutex/timeout.rs | UTF-8 | 2,298 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use crate::mutex::{CustomMutex, CustomMutexGuard, RawMutex, TryMutex, TryMutexSized};
use core::ops::DerefMut;
use core::time::Duration;
/// A raw mutex that can be timed out and holds no data.
pub unsafe trait RawTimeoutMutex: RawMutex {
/// Locks the mutex on a timeout. Returns true if locked.
fn lock_timeou... | true |
bb691100db0f10f75c28ea05595fd0149c37f919 | Rust | isgasho/drue | /src/bin/drue.rs | UTF-8 | 2,623 | 2.625 | 3 | [] | no_license | #[macro_use]
extern crate clap;
use crate::core::*;
use algorithms::*;
use drue::*;
use huemanity::Bridge;
// TODO: Implement default algorithms
/// Main entrypoint for the CLI
fn main() {
println!(
"
________________________________________________________________________________
██████╗ ██████... | true |
88e7f65557475c881b17b58d3f43d4fd53e2814e | Rust | erochest/git-branch-stack | /src/actions/pop.rs | UTF-8 | 478 | 2.78125 | 3 | [] | no_license | /// # Pop Command
///
/// This implements the `pop` command.
use git2::Repository;
use crate::errors::{BranchStackError, Result};
use crate::git::change_branch;
use crate::stack::FileStack;
pub fn pop_branch_stack(repo: &Repository, stack: &mut FileStack) -> Result<()> {
stack
.pop()
.ok_or(Branch... | true |
897ee40c85195de6234d194b96ea47572a88e533 | Rust | electricherd/audiobookfinder | /native/adbflib/src/net/sm_behaviour.rs | UTF-8 | 5,325 | 2.53125 | 3 | [
"MIT"
] | permissive | //! Taken from dummy behaviour to have a layer of communication which reacts with
//! the embedded state machine (and inner ui), also back to net services:
//! currently kademlia, mdns
//! https://docs.rs/libp2p/latest/libp2p/swarm/struct.DummyBehaviour.html
use super::{
super::data::ipc::{IFCollectionOutputData, I... | true |
89f78d687de1dac514793dfd7e7e094d53238ca9 | Rust | isgasho/MoonZoon | /crates/zoon/src/cache.rs | UTF-8 | 3,180 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::runtime::CACHES;
use crate::cache_map::{Id, Creator};
use crate::relations::__Relations;
use crate::block_call_stack::__Block;
use std::marker::PhantomData;
use std::any::Any;
pub fn cache<T: 'static>(id: Id, creator: impl FnOnce() -> T + Clone + 'static) -> Cache<T> {
let id_exists = CACHES.with(|cache... | true |
229524945fba42da3c4978b3a3a96382a5f98da2 | Rust | deepinthebuild/rust-wfc | /src/overlappingmodel.rs | UTF-8 | 18,730 | 2.515625 | 3 | [] | no_license | #![allow(dead_code)]
use utils::*;
use bit_vec::BitVec;
use sourceimage::{Color, SeedImage};
use png::{Encoder, ColorType, BitDepth, HasParameters};
use ndarray::prelude::*;
use rand;
use std::collections::HashMap;
use std::cell::RefCell;
use std::{f64, usize};
use std::hash::Hash;
use std::convert::TryInto;
use st... | true |
404cf98f426179a0b83df8aa1aaf52a15eb4843f | Rust | melkibalbino/rust-conc-e-perf-seguro | /08-testar-o-tempo-todo/calculator-01/tests/method_test.rs | UTF-8 | 537 | 3.171875 | 3 | [] | no_license | extern crate calculator_01;
#[test]
fn sum_test() {
assert_eq!(4, calculator_01::sum(2, 2));
assert_eq!(10, calculator_01::sum(8, 2));
}
#[test]
fn subtract_test() {
assert_eq!(0, calculator_01::subtract(2, 2));
assert_eq!(6, calculator_01::subtract(8, 2));
}
#[test]
fn multiply_test() {
assert_e... | true |
031466505c38231d7e4bd148d5b2d715441f18f4 | Rust | clark-lindsay/geometry | /src/canvas.rs | UTF-8 | 3,285 | 3.40625 | 3 | [] | no_license | use crate::pixel;
use crate::color;
use std::ops::IndexMut;
use std::ops::Index;
#[derive(Clone)]
pub struct Canvas {
width: usize,
height: usize,
pixels: Vec<Vec<pixel::Pixel>>
}
pub fn new(height: usize, width: usize) -> Canvas {
let pixels = vec![vec![pixel::new(color::new(0.0, 0.0, 0.0)); width]; ... | true |
0c7375066e00d0fb2a08e2f74cda9c0399275850 | Rust | slowli/arithmetic-parser | /typing/src/lib.rs | UTF-8 | 10,713 | 3.609375 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Hindley–Milner type inference for arithmetic expressions parsed
//! by the [`arithmetic-parser`] crate.
//!
//! This crate allows parsing type annotations as a part of a [`Grammar`], and to infer
//! and check types for expressions / statements produced by `arithmetic-parser`.
//! Type inference is *partially* comp... | true |
5881853f8e6a9e3292071ba853a3899cead25d1b | Rust | aurumcodex/othello | /rust/src/othello/bot.rs | UTF-8 | 4,869 | 2.984375 | 3 | [
"MIT",
"MPL-2.0"
] | permissive | // bot.rs
#![allow(clippy::ptr_arg)]
use std::collections::HashMap;
// use rand::prelude::*;
use crate::othello::{algorithms::Algorithm, moves::Move, player::Player, Board};
pub enum MoveType {
Auto, // automatically decide which move type would be best to use at current state
RNG,
AlphaBeta, // fail-so... | true |
e79fd097c9034d4722b3ad5a391b72587fc70b25 | Rust | pantsbuild/pants | /src/rust/engine/concrete_time/src/lib.rs | UTF-8 | 4,562 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to... | true |
f1f9ab28ea0a5629ec26b5f57c7c4fef303d6960 | Rust | mzumi/rust-aws-lambda | /division_calculator/src/main.rs | UTF-8 | 874 | 2.90625 | 3 | [] | no_license | #[macro_use]
extern crate lambda_runtime as lambda;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate log;
extern crate simple_logger;
use lambda::error::HandlerError;
use std::error::Error;
#[derive(Deserialize, Clone)]
struct CustomEvent {
x: i64,
y: i64,
}
#[derive(Serialize, Clone)]
stru... | true |
0c86b600b6c6609b2c01117529ac7d50fbd779a5 | Rust | King-Coyote/ciso-rust | /src/events/event_queue.rs | UTF-8 | 1,216 | 3 | 3 | [] | no_license | use crate::events::{Event,};
use crossbeam_channel::{Sender, Receiver, unbounded,};
pub struct EventQueue {
inbound: Receiver<Event>,
outbound_tx: Sender<Event>,
}
impl EventQueue {
pub fn new() -> (Sender<Event>, Receiver<Event>, EventQueue) {
let (inbound_tx, inbound_rx) = unbounded();
l... | true |
c7f804fbeb3e5ee9fa94876afcdba7029ee5951d | Rust | okamotonr/hack_assembler | /src/code.rs | UTF-8 | 3,946 | 3.203125 | 3 | [] | no_license | use std::collections::HashMap;
use crate::parser::AsmLine;
#[derive(Debug)]
struct SymbolTable {
table: HashMap<String, u32>,
rom_address: u32,
index: u32,
limit: u32,
}
impl SymbolTable {
pub fn new() -> Self {
let mut table = HashMap::new();
let mut index = 0;
let defalu... | true |
5ca9c47abcdeb00ebc3f0e7fb5b0d0e828d36426 | Rust | DarthStrom/2020-Rust-Advent-of-Code | /src/day06.rs | UTF-8 | 1,354 | 3.515625 | 4 | [] | no_license | pub fn solve1(lines: &Vec<&str>) -> usize {
let groups = lines.split(|line| line.is_empty());
groups
.map(|group| {
let mut group_vec = group.to_vec().join("").chars().collect::<Vec<_>>();
group_vec.sort();
group_vec.dedup();
group_vec.len()
})
... | true |
502352b18b008e387fd690cca6e8e5258aa76b1f | Rust | kezenator/adventofcode | /2020/src/y2019/d23/mod.rs | UTF-8 | 2,259 | 2.859375 | 3 | [
"MIT"
] | permissive | use crate::support::*;
use crate::y2019::intcode::Intcode;
const INPUT: &str = include_str!("input.txt");
fn run(part_2: bool) -> i64
{
let mut computers: Vec<Intcode> = Vec::new();
for addr in 0..50
{
computers.push(Intcode::new_from_input(INPUT));
computers.last_mut().unwrap().input(add... | true |
780f19583b5cfde016b97ebb70ce55bee6c7bc88 | Rust | sgreenlay/aoc-2019 | /src/day25.rs | UTF-8 | 10,620 | 3.03125 | 3 | [] | no_license | use std::collections::HashMap;
use std::io;
use std::fmt;
use regex::Regex;
use lazy_static;
use crate::intcode::{VirtualMachine, VirtualMachineState, load_program};
#[derive(PartialEq, Clone, Copy)]
enum Direction {
North,
South,
East,
West
}
impl Direction {
fn inverse(&self) -> Direction {
... | true |
b96d8da907598f6a1b029ed488b6b206c8efc8e9 | Rust | wlh320/shuaOJ | /ProjectEuler/Euler/src/bin/p057.rs | UTF-8 | 296 | 2.890625 | 3 | [] | no_license | use num_bigint::BigUint;
fn main() {
let (mut a, mut b) = (BigUint::from(0u32), BigUint::from(1u32));
let mut ans = 0;
for _ in 0..1000 {
let temp = b.clone();
b = b * 2u32 + &a;
a = temp;
if (&a+&b).to_string().len() > b.to_string().len() {
ans += 1;
}
}
println!("{}", ans);
} | true |
f369abd057d889cfd71e49ceec6024bc68fc6727 | Rust | traviskaufman/piet-rs | /src/color_block.rs | UTF-8 | 3,033 | 3.1875 | 3 | [] | no_license | use std::collections::HashSet;
use std::cmp::Ordering;
use image::RgbImage;
use state::{Position, Direction};
use util;
// See: https://en.wikipedia.org/wiki/Flood_fill
// Inspired by how npiet does color block checking
fn flood_check(img: &RgbImage, x: i32, y: i32, mut blk: &mut ColorBlock) {
let out_of_bounds ... | true |
fe5948d5f6945cc2d45a6087e048dfdb5d0ff84c | Rust | laptou/bluez-rs | /src/management/client/oob.rs | UTF-8 | 5,775 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::AddressType;
use enumflags2::BitFlags;
use super::interact::{address_bytes, get_address};
use super::*;
use crate::util::BufExt;
/// This command is used to read the local Out of Band data.
///
/// This command can only be used when the controller is powered.
///
/// If Secure Connections support is enable... | true |
d1cefdc9eae68c5a560ef646ea5601f811b0703e | Rust | hyber-gp/hyber | /src/widget/slider.rs | UTF-8 | 15,588 | 3.1875 | 3 | [
"MIT"
] | permissive | use crate::event;
use crate::event::Event;
use crate::renderer::{Message, RenderInstruction};
use crate::util::{Color, Queue, Vector2D};
use crate::widget::{Layout, Widget};
use std::cell::RefCell;
use std::rc::Weak;
/// Current slider position
#[derive(Clone)]
pub struct Position {
/// The current value of the s... | true |
bf81b843e68a67e245a927797f56bec056afb359 | Rust | tdgne/voicething | /src/audio/stream/dewindower.rs | UTF-8 | 3,677 | 2.671875 | 3 | [] | no_license | use super::super::common::*;
use super::node::*;
use getset::Getters;
use serde::{Deserialize, Serialize};
use std::collections::VecDeque;
#[derive(Getters, Serialize, Deserialize, Debug)]
pub struct Dewindower {
io: NodeIo,
id: NodeId,
#[serde(skip)]
buffer: Vec<VecDeque<f32>>,
out_chunk_size: usi... | true |
f2bac69816d2d175f48c27d12c6f8cefd7c4d85d | Rust | konradsz/adventofcode2020 | /day20/src/main.rs | UTF-8 | 10,084 | 3.28125 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
use std::fs;
const WIDTH: usize = 10;
type Orientation = (bool, u8);
const ORIENTATIONS: [Orientation; 8] = [
(false, 0),
(false, 1),
(false, 2),
(false, 3),
(true, 0),
(true, 1),
(true, 2),
(true, 3),
];
const SEA_MONSTER: [&str; 3] = [
"... | true |
f96642667f8f2c43afb6804c86cb7b14c6eb209d | Rust | jTitor/leek2 | /src/open-source/engine/modules/src/math/linear_algebra/vec_base.rs | UTF-8 | 1,462 | 3.59375 | 4 | [] | no_license | /*!
Base traits for vector operations.
Represents a generic vector.
#Implementing Equality
By default, vectors should use nearly_equal in their comparison operations.
*/
pub trait VecOps<T=Self> {
///Gets the i'th element of this vector.
/// # Panics if:
/// * i is out of range [0, num_elems()-1]
fn elem_at(&s... | true |
9cece3cace689a8914bb321ed76c92f8e5cd315b | Rust | commieprincess/aoc2017 | /day_20/src/main.rs | UTF-8 | 2,572 | 3.1875 | 3 | [] | no_license | use std::collections::HashSet;
fn main() {
let input : Vec<Vec<&str>> = include_str!("input.txt").trim().lines().map(|x| x.split(',').map(|y| y.trim()).collect::<Vec<&str>>()).collect();
let mut input : Vec<Particle> = input.iter().map(|vec| {
let x0 : i64 = vec[0][3..].parse().unwrap();
let y0 = ve... | true |
80c7b7f0bcc805bf0af0ec43e0917fec74bbc7d5 | Rust | hexium310/git-issue | /src/main.rs | UTF-8 | 3,072 | 3.046875 | 3 | [
"MIT"
] | permissive | #![cfg_attr(test, allow(unused_imports))]
#[macro_use]
extern crate clap;
use std::process::Command;
use std::str;
use clap::{ App, ArgMatches };
use regex::Regex;
mod subcommands;
use crate::subcommands::*;
#[cfg(not(test))]
fn main() {
let yaml = load_yaml!("cli.yml");
let mut matcher = App::from_yaml(... | true |
f790cc11cd7450af153d04c6ace590d95030d282 | Rust | tinetti/krust | /src/lib.rs | UTF-8 | 3,544 | 3.171875 | 3 | [] | no_license | use clap::{App, Arg, ArgMatches, SubCommand};
fn create_clap_app<'a, 'b>() -> App<'a, 'b> {
let broker_arg = Arg::with_name("broker")
.short("b")
.long("broker")
.value_name("broker")
.help("Bootstrap broker(s)")
.multiple(true)
.takes_value(true);
return App::n... | true |
e18404f62c617f5b80b796ac76ee8d6b2dd732b5 | Rust | tomzhang/scylla-rust-driver | /scylla/src/frame/types.rs | UTF-8 | 9,614 | 2.75 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! CQL binary protocol in-wire types.
use anyhow::Result;
use byteorder::{BigEndian, ReadBytesExt};
use bytes::BufMut;
use std::collections::HashMap;
use std::str;
use uuid::Uuid;
use crate::frame::value::Value;
fn read_raw_bytes<'a>(count: usize, buf: &mut &'a [u8]) -> Result<&'a [u8]> {
if buf.len() < count {... | true |
b82bdce3faac06b70476ba4580acc46c61680ad8 | Rust | tycobbb/scribe-lite | /api/src/core/socket/socket.rs | UTF-8 | 1,197 | 2.828125 | 3 | [] | no_license | use super::channel::Channel;
use super::routes::Routes;
use crate::core::empty;
use yansi::{Color, Paint};
// constants
const HOST: &'static str = "127.0.0.1:8080";
// -- types --
pub struct Socket;
// -- impls --
impl Socket {
// -- impls/commands
pub fn listen<R>(&self, routes: R)
where
R: Rout... | true |
5f625ac627328ca56a8300fc601546c5ae92c23f | Rust | Anwesh43/rust-udemy-course-practice | /union_demo.rs | UTF-8 | 435 | 3.484375 | 3 | [] | no_license | union IntOrFloat {
i : i32,
f : f32
}
fn check_value(un : IntOrFloat) {
unsafe {
match un {
IntOrFloat {i : 5} => println!("value is {}", un.i),
IntOrFloat {f} => println!("float value is {}", un.f)
}
}
}
fn main() {
let un = IntOrFloat {i : 5};
unsafe... | true |
631007cc1a3fe2dff3fca1c4209f94f07dafa100 | Rust | 0b01/dyn-grammar | /src/grammar/test_grammar.rs | UTF-8 | 11,463 | 3.28125 | 3 | [] | no_license | use crate::grammar::*;
use self::Token::*;
macro_rules! sentence {
($($i: ident),*) => {
{
let mut v = vec![];
$(
v.push(Terminal(stringify!($i)));
)*
v
}
};
}
#[test]
fn test_parse_simple_grammar() {
// Grammar
// S -> a... | true |
0c06f453765db5dbb0d9473855df5e8203c88a43 | Rust | davechallis/rust-raytracer | /src/material/metal.rs | UTF-8 | 1,159 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use crate::vec3::Vec3;
use crate::ray::Ray;
use crate::hitable::HitRecord;
use super::Material;
use crate::utils;
use crate::texture::Texture;
#[derive(Clone)]
pub struct Metal<T: Texture + Clone> {
albedo: T,
fuzz: f32,
}
impl<T: Texture + Clone> Metal<T> {
pub fn new(albedo: T, fuzz: f32) -> Self {
... | true |
2e098963e0c9681af52939f017589e754b2d1086 | Rust | mahimachander/slide | /libslide/src/utils/iter.rs | UTF-8 | 4,108 | 3.90625 | 4 | [
"BSD-3-Clause"
] | permissive | use std::collections::VecDeque;
use std::vec::IntoIter;
/// A [`TakeWhile`]-like struct that tests a predicate by peeking rather than consuming an iterator.
///
/// rustlib's [`TakeWhile`] consumes items in an iterator until its predicate is no longer satisfied.
/// This means that the first item that fails the predic... | true |
08d0d3e2e2e6773bc55512034288a18ac0d8037c | Rust | image-rs/canvas | /canvas/benchmarks/bitpack.rs | UTF-8 | 2,523 | 3.109375 | 3 | [] | no_license | //! Benchmarks sRGB to sRGB conversions.
use brunch::Bench;
use image_canvas::color::Color;
use image_canvas::layout::{Block, CanvasLayout, LayoutError, SampleBits, SampleParts, Texel};
use image_canvas::Canvas;
struct Convert {
texel_in: Texel,
color_in: Color,
texel_out: Texel,
color_out: Color,
... | true |
fe0188ed81fd2a3d7356d10f3d1bd4d9c83fb0b2 | Rust | Sanya2007/stm32_rust | /src/stm32f4xx/regs/pwr.rs | UTF-8 | 2,653 | 2.71875 | 3 | [] | no_license | #![allow(dead_code)]
//! Power Control registers
use ::volatile_reg32::*;
use super::constants::PWR_BASE;
pub struct PwrRegs
{
/// PWR power control register
pub cr : VolatileReg32,
/// PWR power control/status register
pub csr : VolatileReg32,
}
impl PwrRegs {
pub fn init() -> PwrRegs {
... | true |
ffe50a6372829c5db54312da5ce230dd9336e82d | Rust | utilForever/BOJ | /Rust/26071 - Chongchong who went to Arcade.rs | UTF-8 | 2,621 | 3.140625 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
buf_str: vec![],
buf_iter: ""... | true |
3eb6e41aa922bd9bae9c4ce7d9d79553ff52a6ef | Rust | devinschulz/advent-of-code | /2015/src/day01/mod.rs | UTF-8 | 697 | 3.40625 | 3 | [] | no_license | fn input() -> &'static str {
include_str!("input.txt")
}
fn part1(input: &str) -> i32 {
input.chars().fold(0, |acc, x| match x {
')' => acc - 1,
'(' => acc + 1,
_ => acc,
})
}
fn part2(input: &str) -> usize {
let mut pos = 0i32;
for (index, char) in input.chars().enumerate(... | true |
8a3c667495b56155845dee4b67709d0afdaedf07 | Rust | CollinValley/Exercism-rust | /nth-prime/src/lib.rs | UTF-8 | 449 | 3.515625 | 4 | [] | no_license | fn is_prime(num: u32) -> bool {
let mut ret = true;
for i in 2 .. num {
if num % i == 0 {
ret = false;
break;
}
}
ret
}
pub fn nth(n: u32) -> u32 {
let mut max_prime = 2;
let mut number = 2;
let mut nth = n;
while nth > 0 {
number = numb... | true |
7566c1a068275b7997cfebf428870c1a0dc6b12f | Rust | TimonPost/anasaizi | /anasaizi-core/src/vulkan/layer.rs | UTF-8 | 2,768 | 3.015625 | 3 | [] | no_license | use crate::utils::vk_to_string;
use ash::version::EntryV1_0;
use std::fmt;
pub struct VkValidationLayerProperties {
pub name: String,
pub description: String,
pub specs_version: u32,
pub implementation_version: u32,
}
/// Validation layers are optional components that hook into Vulkan function calls t... | true |
0c41a6afe32b49fd9a52c2cf4b2ef0e4d0d733c0 | Rust | wedaly/devlog | /src/status.rs | UTF-8 | 12,892 | 3.21875 | 3 | [
"MIT"
] | permissive | //! Report tasks from the most recent devlog entry file,
//! grouped by task status type.
use crate::error::Error;
use crate::file::LogFile;
use crate::repository::LogRepository;
use crate::task::{Task, TaskStatus};
use std::io::Write;
/// Controls how tasks are displayed in the status report.
#[derive(Debug, Copy, C... | true |
8e46272222884862ad2c9eb7b714d79319a3f72c | Rust | zhao1jin4/vscode_rust_workspace | /cargo_projects/third_parent/third_wasm/src/main.rs | UTF-8 | 129 | 2.53125 | 3 | [] | no_license | use third_gtk4;
fn main() {
let num = 10;
println!("Hello, world! {} plus one is {}!", num, third_gtk4::add_one(num));
} | true |
6504c2ab4a99a5ef906154106fcf9fce7f9d8779 | Rust | pop-os/gir | /src/codegen/property_body.rs | UTF-8 | 5,462 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::{
analysis,
chunk::Chunk,
env::Env,
nameutil::{use_glib_type, use_gtk_type},
};
pub struct Builder<'a> {
name: String,
in_trait: bool,
var_name: String,
is_get: bool,
is_child_property: bool,
type_: String,
env: &'a Env,
}
#[allow(clippy::wrong_self_convention)]
... | true |
3620ad392aa93d6a1b470e03fe329a1f3b8c4fa6 | Rust | turnikuta/iota-base-rs | /src/create_value_transaction/get_account_info.rs | UTF-8 | 1,589 | 2.65625 | 3 | [] | no_license |
use std::env;
use std::process::exit;
use anyhow::Result;
use iota_base_rs::{generate_named_seed,
prepare_iota_seed,
get_address_trytes};
#[tokio::main]
async fn main() -> Result<()> {
let args: Vec<_> = env::args().collect::<Vec<_>>();
if args.len() < 2 {
epri... | true |
da4e8d889f854e292865564dbeec8d4e6c986ba0 | Rust | rayon-rs/rayon | /src/iter/map_with.rs | UTF-8 | 14,235 | 3.078125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::plumbing::*;
use super::*;
use std::fmt::{self, Debug};
/// `MapWith` is an iterator that transforms the elements of an underlying iterator.
///
/// This struct is created by the [`map_with()`] method on [`ParallelIterator`]
///
/// [`map_with()`]: trait.ParallelIterator.html#method.map_with
/// [`Parallel... | true |
16397b3f3bf22b89d8ed34c94f78c91b6dde7e7a | Rust | binp-dev/ksfc-lxi | /src/main.rs | UTF-8 | 3,934 | 2.515625 | 3 | [
"MIT"
] | permissive | //#![allow(dead_code)]
use std::time::{Duration};
use std::thread::{sleep};
use ksfc_lxi::{
KsFc, Error,
types::{EventReg, ChannelNo, TriggerSource},
};
static FREQ: f64 = 7e3;
static FREPS: f64 = 1e-2;
static MEAS_TIME: Duration = Duration::from_secs(1);
fn assert_feq(val: f64, refv: f64, reps: f64) {
... | true |
0d30b724a0bfb05fb04e9791bcd8b326c51c4efc | Rust | emlaufer/juntos | /src/multiboot/tag/mod.rs | UTF-8 | 6,998 | 2.875 | 3 | [] | no_license | pub mod elf_symbols;
pub mod memory_map;
use core::marker::PhantomData;
use core::{slice, str};
pub use elf_symbols::ElfSymbols;
pub use memory_map::MemoryMap;
pub struct TagIterator<'a> {
current_tag: *const TagHeader,
_marker: PhantomData<&'a TagHeader>,
}
impl<'a> TagIterator<'a> {
/// # Safety
/... | true |
469068dfe25eb1bf538019bee414dcd29d316d1f | Rust | BurntSushi/fst | /fst-levenshtein/src/lib.rs | UTF-8 | 9,793 | 3.4375 | 3 | [
"MIT",
"Unlicense"
] | permissive | use std::cmp;
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet};
use std::fmt;
use utf8_ranges::{Utf8Range, Utf8Sequences};
use fst::automaton::Automaton;
pub use self::error::Error;
mod error;
const STATE_LIMIT: usize = 10_000; // currently at least 20MB >_<
/// A Unicode aware Leve... | true |
218f8fc2360c825274f831d5163600e6d9a9c15f | Rust | TheCharlatan/bitbox02-firmware | /src/rust/apps/ethereum/src/keypath.rs | UTF-8 | 3,678 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Shift Cryptosecurity AG
//
// 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 ... | true |
d3c71e35fb65c13ad2d23f3b06b15a8842386b3c | Rust | thehabbos007/anchors | /src/ext.rs | UTF-8 | 12,986 | 3.5625 | 4 | [] | no_license | use super::{Anchor, AnchorInner, Engine};
use std::panic::Location;
mod cutoff;
mod map;
mod map_mut;
mod refmap;
mod then;
/// A trait automatically implemented for all Anchors.
/// You'll likely want to `use` this trait in most of your programs, since it can create many
/// useful Anchors that derive their output i... | true |
5379db9f5e82c058c464bfb01f21cec8121c9a10 | Rust | rrcoco/test_2018_2021 | /18_rust/HelloWorld/comments.rs | UTF-8 | 150 | 2.53125 | 3 | [
"MIT"
] | permissive | /// lib doc for follow item
fn main() {
let x = 5+ /* 90 + */ 5; /// lib dod for this line item
println!("Is `x` 10 or 100? x = {}, {}", x, x*x);
}
| true |
a8231884273f52382eb63a596830a6752f7977d3 | Rust | JialuGong/leetcode-rust | /rust-ac/1385.find-the-distance-value-between-two-arrays.55737591.ac.rs | UTF-8 | 270 | 2.765625 | 3 | [] | no_license | impl Solution {
pub fn find_the_distance_value(arr1: Vec<i32>, arr2: Vec<i32>, d: i32) -> i32 {
let mut cnt:i32=0;
for i in &arr1{
let mut flag=true;
for j in &arr2{
if (i-j).abs()<=d {flag=false;break;}
}
if flag {cnt+=1;}
}
cnt
}
}
| true |
51f7d4aec92efb9e137b8c4fb9286f86ed5de222 | Rust | silverweed/ecsde | /inle/inle_core/src/env.rs | UTF-8 | 2,458 | 2.96875 | 3 | [] | no_license | use std::boxed::Box;
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
#[derive(Clone)]
pub struct Env_Info {
pub full_exe_path: Box<Path>,
pub working_dir: Box<Path>,
pub assets_root: Box<Path>,
pub cfg_root: Box<Path>,
}
impl Env_Info {
pub fn gather() -> std::io::R... | true |
e79093b5e198c6ee8949d56c74336d931e9148f6 | Rust | steadylearner/Rust-Full-Stack | /database/sqlite_rust/src/main_crud_prototype.rs | UTF-8 | 4,308 | 3.4375 | 3 | [
"MIT"
] | permissive | use std::io::stdin;
use rusqlite::NO_PARAMS;
use rusqlite::{params, Connection, Result};
// // https://docs.rs/time/0.2.9/time/struct.Instant.html
// use time::Instant;
// https://github.com/jgallagher/rusqlite#optional-features - chrono
// Refer to Cargo.toml
use chrono::naive::NaiveDateTime;
// 1. created_at: Nai... | true |
b60007262963bacafa1e7adb050ba1af54828cf1 | Rust | sugyan/leetcode | /problems/0560-subarray-sum-equals-k/lib.rs | UTF-8 | 659 | 3.4375 | 3 | [] | no_license | use std::collections::HashMap;
pub struct Solution;
impl Solution {
pub fn subarray_sum(nums: Vec<i32>, k: i32) -> i32 {
let mut hm = HashMap::from([(0, 1)]);
let (mut sum, mut answer) = (0, 0);
for num in &nums {
sum += num;
answer += hm.get(&(sum - k)).unwrap_or(&... | true |
476bf53588e5303ed308a8196843bc419bf8ddfd | Rust | hunterlester/safe_cli | /tests/safe_authenticator_service_integration.rs | UTF-8 | 3,587 | 2.5625 | 3 | [
"MIT"
] | permissive | use actix_web::{http::Method, test, App, HttpMessage};
use rand::Rng;
use safe_authenticator::{AuthError, Authenticator};
use safe_cli::{authorise, create_acc, index, login, AuthenticatorStruct};
use std::str::from_utf8;
use std::sync::{Arc, Mutex};
fn create_test_service() -> App<AuthenticatorStruct> {
let handle... | true |
e989c21fcd8378d065a73abc33e25c924f8cff15 | Rust | leontoeides/google_maps | /src/roads/snap_to_roads/mod.rs | UTF-8 | 2,202 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! The Roads API **Snap To Roads** service takes up to 100 GPS points collected
//! along a route, and returns a similar set of data, with the points snapped to
//! the most likely roads the vehicle was traveling along. Optionally, you can
//! request that the points be interpolated, resulting in a path that smoothly
... | true |
079fe8e50ed2fc8eeafff9440c96459194e641ea | Rust | RafeWoo/asteroids | /src/states/pause.rs | UTF-8 | 2,254 | 3.421875 | 3 | [] | no_license | //! PauseState is entered when player has paused gameplay
//!
//! Can go to gameplay state
//! Waiting for player to press unpause key
//!
//! Display "Paused" on Screen
//! set a paused flag
use amethyst::{
ecs::prelude::*,
input::is_key_down,
prelude::*,
renderer::VirtualKeyCode,
ui::{Anchor, Ui... | true |
3b3be686e1093557b7a24b69a868404539b7bf14 | Rust | rust-lang/miri | /tests/pass/char.rs | UTF-8 | 163 | 2.765625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | fn main() {
let c = 'x';
assert_eq!(c, 'x');
assert!('a' < 'z');
assert!('1' < '9');
assert_eq!(std::char::from_u32('x' as u32), Some('x'));
}
| true |
8aa166e8b21502a265329f4ee98a2e8a3662a289 | Rust | Caruso33/rust | /ultimate_rust_crash_course/exercise/z_final_project/src/lib.rs | UTF-8 | 222 | 2.875 | 3 | [
"MIT"
] | permissive | use std::fs::create_dir;
use std::path::Path;
pub fn create_output_if_not_exist(output_path: &Path) -> () {
if !output_path.exists() {
create_dir(output_path).expect("Can't create output directory");
};
}
| true |
ebb6299c51787534004c66604718b87e5e891561 | Rust | Lawliet-Chan/phala-pruntime | /vendor/rustcrypto-utils/hex-literal/hex-literal-impl/src/lib.rs | UTF-8 | 1,446 | 3.0625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | extern crate proc_macro;
use proc_macro::{TokenStream, TokenTree};
use proc_macro_hack::proc_macro_hack;
fn is_hex_char(c: &char) -> bool {
match *c {
'0'...'9' | 'a'...'f' | 'A'...'F' => true,
_ => false,
}
}
fn is_format_char(c: &char) -> bool {
match *c {
' ' | '\r' | '\n' | '\... | true |
c44e6b99d6bda5afcba63a07e266a52eacbed8ea | Rust | rust-lang/rust | /tests/ui/parser/ident-recovery.rs | UTF-8 | 335 | 3.125 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | fn ,comma() {
//~^ ERROR expected identifier, found `,`
struct Foo {
x: i32,,
//~^ ERROR expected identifier, found `,`
y: u32,
}
}
fn break() {
//~^ ERROR expected identifier, found keyword `break`
let continue = 5;
//~^ ERROR expected identifier, found keyword `continue`
}... | true |
c4aa71bedce3cb8ea78a285d1f1462a04af6ca8d | Rust | alex-dranoel/advent-of-code | /2018/Day1_ChronalCalibration/rust/chronal_calibration/src/main.rs | UTF-8 | 954 | 3.453125 | 3 | [] | no_license | use std::{
fs::File,
io::{BufRead, BufReader},
path::Path,
str::FromStr,
fmt::Debug,
collections::HashSet,
};
fn vec_from_file<T: FromStr>(filename: impl AsRef<Path>) -> Vec<T>
where T::Err: Debug
{
BufReader::new(File::open(filename).expect("Could not open file"))
.lines()
... | true |
b70b97419b055de6e6d3e741448ee5923b228333 | Rust | heavypackets/rusty-datatypes | /examples/sigma_p.rs | UTF-8 | 2,156 | 3.015625 | 3 | [] | no_license | #![feature(try_from)]
#![feature(custom_attribute)]
extern crate rusty_dt;
use std::convert::TryFrom;
#[derive(Debug)]
#[sigma_p(derive = "PartialEqA, Add")]
struct CalendarMonth(u32, u8);
impl std::convert::TryFrom<u32> for CalendarMonth {
type Error = u32;
fn try_from(day: u32) -> std::result::Result<Cal... | true |
b3bb36684ec30b4677a3ce61ed9685b5394ebea6 | Rust | lonesometraveler/img-to-byte-array | /src/img2bytes.rs | UTF-8 | 1,967 | 3.1875 | 3 | [
"MIT"
] | permissive | //! # LCD bitmap
//!
//! Usage: cargo run path_to_image name_of_array > file_to_be_saved
//! Example: cargo run sample/arrow_up.png arrow_up > sample/arrow_up.h
use image::Luma;
use std::path::Path;
pub struct ImgToBytes {
file: String,
array_name: String,
}
impl ImgToBytes {
pub fn new(mut args: std::en... | true |
367ead1340ff454c5ac86b4ad3470b93a2d036bc | Rust | dstreet26/adventofcode | /2020/day5/src/main.rs | UTF-8 | 1,526 | 3.609375 | 4 | [] | no_license | use std::collections::HashSet;
use std::fs;
fn main() {
let contents = fs::read_to_string("input.txt").expect("Couldn't read input file :(");
let list: Vec<&str> = contents.split("\n").collect();
let mut highest = 0;
for i in &list {
let x = get_front_or_back(&i[..7]);
let y = get_left... | true |
d919f6dc34a5e3c09ca85f0e55ce9884ae2c5d54 | Rust | gakonst/ethers-structopt | /src/lib.rs | UTF-8 | 2,296 | 2.78125 | 3 | [] | no_license | use ethers::{prelude::*, signers::coins_bip39::English};
use std::convert::TryFrom;
use std::str::FromStr;
use structopt::StructOpt;
// TODO: Add more options, e.g. for generic CLI-type calls
#[derive(StructOpt, Debug, Clone)]
pub struct EthereumOpts {
#[structopt(long = "eth.url", short, help = "The tracing / ar... | true |
8cb64208254fe996b6f9e2873b843febe7505126 | Rust | erismart/ErlangRT | /src/term/raw/rcons.rs | UTF-8 | 1,185 | 3.03125 | 3 | [] | no_license | use defs::Word;
use term::lterm::LTerm;
pub struct RawConsMut {
p: *mut Word,
}
impl RawConsMut {
pub fn from_pointer(p: *mut Word) -> RawConsMut {
RawConsMut { p }
}
pub unsafe fn set_hd(&self, val: LTerm) {
*self.p = val.raw()
}
pub unsafe fn set_tl(&self, val: LTerm) {
*self.p.offset(1) =... | true |
df248cd021eb93227c844fffcbc9ae14fc4ae276 | Rust | daviswahl/monkey_rs | /src/sandbox.rs | UTF-8 | 1,828 | 3.5625 | 4 | [] | no_license | struct Node<'a> {
token: Token<'a>,
node: &'a Node<'a>
}
#[derive(Clone, Copy)]
struct Token<'a> {
literal: &'a [u8],
}
struct LexerCache {
strings: Vec<Vec<u8>>
}
impl LexerCache {
fn push_string(&mut self, s: Vec<u8>) -> &Self {
self.strings.push(s);
self
}
fn last_strin... | true |
10b875205d3b4a78c12459d1be9315fbb8ea34e0 | Rust | getsentry/symbolic | /symbolic-ppdb/src/lib.rs | UTF-8 | 2,934 | 3.03125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Provides support for reading Portable PDB files,
//! specifically line information resolution for functions.
//!
//! [Portable PDB](https://github.com/dotnet/runtime/blob/main/docs/design/specs/PortablePdb-Metadata.md)
//! is a debugging information file format for Common Language Infrastructure (CLI) languages.
//... | true |
33189217e6c70ba9b57e205e987d117a87e831f0 | Rust | RickdeJager/AdventOfCode2020 | /day14/src/main.rs | UTF-8 | 2,582 | 3.140625 | 3 | [] | no_license | use regex::Regex;
use std::collections::HashMap;
fn part1() -> u64 {
let mut mem = HashMap::new();
let re = Regex::new(r"mem\[(?P<idx>\d+)\] = (?P<num>\d+)").unwrap();
let mut mask_or : u64 = 0;
let mut mask_and: u64 = 0;
for line in include_str!("input.txt").lines() {
match &line[..4] {
... | true |
37bdc841627d0bfe85623f4fbc582ae6ff4ff0f6 | Rust | first-rust-competition/first-rust-competition | /wpilib/src/i2c.rs | UTF-8 | 5,910 | 3.125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::cmp;
use std::io;
use wpilib_sys::*;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[repr(i32)]
pub enum Port {
Onboard = HAL_I2CPort::HAL_I2C_kOnboard,
MXP = HAL_I2CPort::HAL_I2C_kMXP,
}
pub struct I2C {
port: Port,
device_address: u16,
}
impl I2C {
/// Constructs a new I2C
///... | true |
1f2d7c709ecb37a992912b0903018bf5c13298eb | Rust | redtankd/project-euler | /src/bin/00037.rs | UTF-8 | 1,594 | 3.171875 | 3 | [] | no_license | use std::collections::BTreeSet;
use project_euler::is_prime;
#[cfg(not(test))]
fn main() {
let t = project_euler::start_timer();
println!("\nsolution:");
println!("The answer is {:?}\n", s1());
project_euler::stop_timer(t);
}
fn s1() -> u32 {
(11..)
.scan(
vec![2, 3, 5, 7].i... | true |
98abf5fcbf33210b9fd44bd880a33a22ecea6c39 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/derive_arbitrary/src/field_attributes.rs | UTF-8 | 3,439 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use
crate
:
:
ARBITRARY_ATTRIBUTE_NAME
;
use
proc_macro2
:
:
{
Span
TokenStream
TokenTree
}
;
use
quote
:
:
quote
;
use
syn
:
:
{
spanned
:
:
Spanned
*
}
;
/
/
/
Determines
how
a
value
for
a
field
should
be
constructed
.
#
[
cfg_attr
(
test
derive
(
Debug
)
)
]
pub
enum
FieldConstructor
{
/
/
/
Assume
that
Arbitrary
is... | true |
c85bde34e3e006b6f54b78d891264c789553edcc | Rust | guangie88/rs-mega-coll | /src/util/process.rs | UTF-8 | 1,584 | 2.609375 | 3 | [] | no_license | use error::custom::{CodeMsgError, MsgError};
use error::{Error, ErrorKind};
use failure::{Context, Fail, ResultExt};
use std::fmt::Debug;
use std::io::Read;
use std::process::{Child, ChildStdout, Output};
pub fn extract_child_stdout<K>(child: Child) -> Result<ChildStdout, Error<K>>
where
K: From<ErrorKind> + Copy ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.