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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
da53974a205021f324f1a252aa1374efe1f57c59 | Rust | linshaoyong/leetcode | /rust/src/easy/e1848_minimum_distance_to_the_target_element.rs | UTF-8 | 640 | 3.609375 | 4 | [
"MIT"
] | permissive | use std::cmp::min;
struct Solution;
impl Solution {
pub fn get_min_distance(nums: Vec<i32>, target: i32, start: i32) -> i32 {
let mut res = nums.len() as i32;
for (i, v) in nums.iter().enumerate() {
if *v == target {
res = min(res, (i as i32 - start).abs());
... | true |
38f5ae5c7e11ae304b318419387d061ec8d9412d | Rust | JakeHuneau/advent_of_code | /src/day5/main.rs | UTF-8 | 1,581 | 3.421875 | 3 | [] | no_license | use advent_of_code::parse_file;
use rayon::iter::ParallelIterator;
use rayon::prelude::*;
// Convert the seats to binary -> u8 and then get seat ID from row * 8 + col. Find the max
// Run in parallel since we can
pub fn solver() {
let data = parse_file::<String>("src/day5/input");
let max_seat = data
.... | true |
3c0352d7343c691a7f6831c4d2d279494c9dc2d3 | Rust | fedelebron/rust-raytracing-in-one-weekend | /src/vec3_scalar.rs | UTF-8 | 6,964 | 3.484375 | 3 | [] | no_license | use rand::Rng;
use std::f32::consts::PI;
use std::ops::{
Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign,
};
type T = f32;
#[derive(Debug, Copy, Clone)]
pub struct Vec3 {
x: T,
y: T,
z: T,
}
impl Vec3 {
pub fn x(&self) -> T {
self.x
}
pub fn y(&self) -> T {
... | true |
ab803fb9b0f4328800a07106c183d1e172f12f24 | Rust | nyantec/ring | /src/agreement.rs | UTF-8 | 12,073 | 2.71875 | 3 | [
"OpenSSL",
"MIT",
"ISC",
"LicenseRef-scancode-mit-taylor-variant",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2015-2017 Brian Smith.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAI... | true |
bd6358b127f599fd5e99365ead5a70439fea7ca9 | Rust | jussi-kalliokoski/advent-of-code-2020 | /day_8.rs | UTF-8 | 3,093 | 3.328125 | 3 | [] | no_license | use std::io::{stdin, BufRead};
use std::str::FromStr;
use std::num::ParseIntError;
use std::collections::HashSet;
fn main() {
let mut instructions = stdin()
.lock()
.lines()
.map(|line| line.unwrap().parse::<Instruction>().unwrap())
.collect();
let first_answer = evaluate_instru... | true |
1d737db6400a4c3dc7fdc6d49dd2d40261fce1f2 | Rust | barzilouik/flowbetween | /anim_sqlite/src/db/insert_editlog.rs | UTF-8 | 6,678 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
use super::db_enum::*;
use super::flo_store::*;
use self::DatabaseUpdate::*;
impl<TFile: FloFile+Send> AnimationDbCore<TFile> {
///
/// Inserts a set of edits into the database
///
pub fn insert_edits(&mut self, edits: &[AnimationEdit]) -> Result<()> {
// Insert all of the edits... | true |
6aba6b2189de6ae8d698806da5f25a1de12863f7 | Rust | superf0sh/solana | /src/leader_confirmation_service.rs | UTF-8 | 6,984 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | //! The `leader_confirmation_service` module implements the tools necessary
//! to generate a thread which regularly calculates the last confirmation times
//! observed by the leader
use crate::service::Service;
use solana_metrics::{influxdb, submit};
use solana_runtime::bank::Bank;
use solana_sdk::pubkey::Pubkey;
use... | true |
f5213c3ca6f86cf58b566dfb14bf40165a1f4229 | Rust | kolmodin/advent-of-code-2020 | /src/bin/day04.rs | UTF-8 | 3,326 | 3.515625 | 4 | [
"Apache-2.0"
] | permissive | extern crate nom;
use nom::{
character::complete::alpha1, character::complete::digit1, combinator::eof, combinator::map_opt,
sequence::pair, sequence::terminated, IResult,
};
use std::collections::HashSet;
use std::fs;
/*
byr (Birth Year) - four digits; at least 1920 and at most 2002.
iyr (Issue Year) - four d... | true |
b8f3dde6f7f2a4a701e8b2cd8635da03061f4adc | Rust | nuta/archives | /noa-next/src/noa/minimap.rs | UTF-8 | 3,352 | 3.234375 | 3 | [
"CC0-1.0"
] | permissive | use std::{collections::BTreeMap, ops::Range, path::Path};
use crate::git::{DiffType, Repo};
#[derive(Debug, Clone, Copy)]
pub enum LineStatus {
AddedLine,
RemovedLine,
ModifiedLine,
Error,
Warning,
Cursor,
}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum MiniMapCategory {
... | true |
58ef2ac1549f9379a12125093ba3cf5e89f48e9f | Rust | PistonDevelopers/image_buffer | /src/traits.rs | UTF-8 | 6,535 | 3.46875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::ops::{Index, IndexMut};
use num_traits::{Bounded, Num, NumCast};
/// A generalized pixel.
///
/// A pixel object is usually not used standalone but as a view into an image buffer.
pub trait Color
: Copy + Clone + AsRef<<Self as Color>::Storage> + AsMut<<Self as Color>::Storage> + 'static
{
/// The... | true |
04861c5a15c660f1c51b8b9c6968ff136fe7436b | Rust | watawuwu/cargo-launcher | /src/fs.rs | UTF-8 | 2,201 | 3.296875 | 3 | [
"MIT"
] | permissive | use std::fs::{self, File};
use std::io::{BufReader, BufWriter, Read, Write};
use std::path::Path;
use crate::error::Result;
pub fn mk_dir<P: AsRef<Path>>(path: P) -> Result<()> {
fs::create_dir_all(path)?;
Ok(())
}
pub fn read_file<P: AsRef<Path>>(path: P) -> Result<Vec<u8>> {
let file = File::open(&path... | true |
1dad190e427b43b437317a4c85cea1fcb1b419ab | Rust | clarkmoody/iced | /native/src/command/action.rs | UTF-8 | 1,879 | 3.125 | 3 | [
"MIT"
] | permissive | use crate::clipboard;
use crate::system;
use crate::widget;
use crate::window;
use iced_futures::MaybeSend;
use std::fmt;
/// An action that a [`Command`] can perform.
///
/// [`Command`]: crate::Command
pub enum Action<T> {
/// Run a [`Future`] to completion.
///
/// [`Future`]: iced_futures::BoxFuture
... | true |
8465e7bbea2118843f91a8497517859b021fd237 | Rust | getong/laminar | /src/error.rs | UTF-8 | 6,930 | 3.25 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! This module contains the laminar error handling logic.
use std::{
error::Error,
fmt::{self, Display, Formatter},
io, result,
};
use crossbeam_channel::SendError;
use crate::SocketEvent;
/// Wrapped result type for Laminar errors.
pub type Result<T> = result::Result<T, ErrorKind>;
#[derive(Debug)]
/... | true |
430a79a9c9c8f6ba0430ef6e877365fbbda55add | Rust | barreiro/euler | /src/main/rust/euler/solver033.rs | UTF-8 | 1,868 | 3.265625 | 3 | [
"MIT"
] | permissive | // COPYRIGHT (C) 2017 barreiro. All Rights Reserved.
// Rust solvers for Project Euler problems
use algorithm::cast::Cast;
use algorithm::digits::DEFAULT_RADIX;
use Solver;
const BASE: u64 = DEFAULT_RADIX as u64;
/// The fraction `49/98` is a curious fraction, as an inexperienced mathematician in attempting to simpl... | true |
f6804c4bb18d83d9be1bf5d98569782681de0e3c | Rust | mtrp12/fp-core.rs | /fp-examples/src/anamorphism_example.rs | UTF-8 | 425 | 3.09375 | 3 | [
"MIT"
] | permissive | use itertools::unfold;
#[test]
fn anamorphism_example() {
let count_down = unfold((8_u32, 1_u32), |state| {
let (ref mut x1, ref mut x2) = *state;
if *x1 == 0 {
return None;
}
let next = *x1 - *x2;
let ret = *x1;
*x1 = next;
Some(ret)
});
... | true |
8e86b4748e96a2eaabf9a07bbfb410551ce93bb5 | Rust | Valodim/rust-rfc2047 | /src/encode.rs | UTF-8 | 4,947 | 3.40625 | 3 | [
"MIT"
] | permissive | use std::borrow::Cow;
const HEX_CHARS: [char; 16] = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
];
pub fn rfc2047_encode(mut data: &str) -> Cow<str> {
if data.is_ascii() {
return Cow::Borrowed(data);
}
let mut result = String::with_capacity(data.len() * 2... | true |
73e172118b9a9b012fa25ed4e335fe4dc06316a4 | Rust | SilverSoldier/ferment | /src/main.rs | UTF-8 | 4,562 | 3 | 3 | [] | no_license | /**
* Grep clone.
* Program which takes a file and a regex as argument and outputs the lines containing regex.
*/
extern crate ansi_term;
extern crate getopts;
use ansi_term::Color::{Green, Red, Blue, Yellow};
use getopts::Options;
use std::env;
use std::fs::{File, metadata, read_dir};
use std::io::BufReader;
use ... | true |
0b7287cb37ec5c73e8f743815d4650d21523925a | Rust | samueldominguez/hodl-ticker | /src/cell.rs | UTF-8 | 1,623 | 3.25 | 3 | [
"MIT"
] | permissive | use prettytable::{Cell, Attr, color};
pub struct LayoutCell {
cell: Cell,
}
impl LayoutCell {
pub fn new() -> LayoutCell {
LayoutCell {
cell: Cell::new(""),
}
}
pub fn set(&mut self, text: &str) -> &mut LayoutCell {
self.cell = Cell::new(text);
self
}
... | true |
ff2c76c35f5cdab6df8f454210a91a4be984515f | Rust | dennisss/dacha | /pkg/fan_controller/src/avr/pins.rs | UTF-8 | 3,477 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | // Pin port configuration and digital I/O.
const DDR_OUTPUT: u8 = 1;
const DDR_INPUT: u8 = 0;
const PORT_PULLUP: u8 = 1;
const PORT_HIGHZ: u8 = 0;
const PORT_HIGH: u8 = 1;
const PORT_LOW: u8 = 0;
macro_rules! define_port {
($name:ident, $pin_addr:expr, $ddr_addr:expr, $port_addr:expr, $( $pin_name:ident : $pin_... | true |
2ebd16b44f27198a048025994d8b9a1cb0760f3d | Rust | dseller/dolrs | /src/document.rs | UTF-8 | 742 | 3.1875 | 3 | [] | no_license |
/*#[derive(Debug)]
pub enum DocumentEntry {
Text(String),
Foreground(String),
Clear
}*/
use crate::parser::{Flag, Flags};
#[derive(Debug,PartialEq)]
pub enum DocumentEntry {
Clear(Flags),
Text(Flags),
Foreground(Flags)
}
#[derive(Debug)]
pub enum DocumentError {
UnrecognizedCommand(Strin... | true |
a65cac26112a36f2155cedc6a5a163f66c47cc56 | Rust | yoshualukash/OS110_MediumExercism | /pythagorean-triplet/src/lib.rs | UTF-8 | 576 | 2.9375 | 3 | [] | no_license | // Pythagorean-triplet
// https://exercism.io/my/solutions/bba562e856614eda9c0b4c2e2c8f15dd
use std::collections::HashSet;
pub fn find(sum: u32) -> HashSet<[u32; 3]> {
let mut triplets = HashSet::new();
for c in 1..sum{
for b in 1..c{
if b + c > sum{
break
}
... | true |
2205cebe915bcf6ec7cd5291e43aaf32db8d2dfc | Rust | supcmd/identity.rs | /bindings/wasm/src/did.rs | UTF-8 | 2,173 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use identity::core::decode_b58;
use identity::iota::DID as IotaDID;
use wasm_bindgen::prelude::*;
use crate::crypto::KeyPair;
use crate::utils::err;
/// @typicalname did
#[wasm_bindgen(inspectable)]
#[derive(Clone, Debug, PartialEq)]
pub str... | true |
863884123ffc3e1b082ecfa4c1584d06798a7197 | Rust | TrevorAC99/RustForOS | /allocate/src/main.rs | UTF-8 | 2,251 | 4.4375 | 4 | [] | no_license | struct Point {
x: f64,
y: f64,
}
impl Point {
fn new(x: f64, y: f64) -> Self {
Self { x, y }
}
fn origin() -> Self {
Self::new(0.0, 0.0)
}
fn distance(&self, other: &Self) -> f64 {
((self.x - other.x).powi(2) + (self.y - other.y).powi(2)).sqrt()
}
}
fn example... | true |
8342492f0282d78146810d8ecff6c324ddc14ba1 | Rust | hoangpq/dora | /src/safepoint.rs | UTF-8 | 4,674 | 2.671875 | 3 | [
"MIT"
] | permissive | use libc;
use parking_lot::{Condvar, Mutex};
use std::ptr;
use std::sync::atomic::{fence, Ordering};
use std::sync::Arc;
use cpu::fp_from_execstate;
use ctxt::{get_vm, VM};
use execstate::ExecState;
use gc::Address;
use os;
use threads::{DoraThread, ThreadState, THREAD};
pub struct PollingPage {
addr: Address,
}
... | true |
699118d8e46fbdadd97d36ff32f1980987a751a4 | Rust | alexander-akhmetov/mos | /src/multitasking/stdio.rs | UTF-8 | 2,111 | 2.59375 | 3 | [] | no_license | use crate::fs::FileDescriptor;
use crate::multitasking::{focus, scheduler};
use alloc::string::String;
use alloc::vec::Vec;
pub struct StdIn {
buffer: Vec<u8>,
pid: u32,
}
impl StdIn {
pub fn new(pid: u32) -> StdIn {
StdIn {
buffer: Vec::new(),
pid,
}
}
}
impl ... | true |
909d124c4d963959185c1d35886b9e04b3a45f3f | Rust | k-hamada/exercism | /rust/prime-factors/src/lib.rs | UTF-8 | 320 | 3.171875 | 3 | [] | no_license | pub fn factors(n: u64) -> Vec<u64> {
let mut number = n;
let mut factors = vec![];
let mut candidate = 2;
while number > 1 {
while number % candidate == 0 {
factors.push(candidate);
number /= candidate
}
candidate += 1
}
factors
}
| true |
48586fe3bbf115033a25120d964a0db835189f14 | Rust | chikoski/rust-exercises | /exercises/reference/src/main.rs | UTF-8 | 462 | 3.25 | 3 | [
"MIT"
] | permissive | /*
ゴール:
1. データをコピーしなくても、greetを呼び出せるようにしてください
2. "Hello dear rustaceans"ではなく、"Hello rustaceans"となるように、
2回目のgreetの呼び出しを行なってください
3. 2をスライスを使って実現してください
*/
fn main() {
let name = format!("dear rustaceans");
greet(name.clone());
greet(name);
}
fn greet(name: String) {
println!("Hello {}", name);
}
| true |
ad42b4edbc7a71b44b2c519156809b3b720b291d | Rust | luizdepra/rust-life | /src/terminal.rs | UTF-8 | 2,187 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::io::{self, Read, Write};
use termion::{self, color, cursor, raw, style};
pub enum Color {
White,
Black,
}
/// A terminal abstraction with input, output and events handling.
#[derive(Debug)]
pub struct Terminal<R, W>
where
R: Read,
W: Write,
{
/// Screen width.
pub width: u16,
//... | true |
85a48071aa0a9f241ec9b178cf1620e6f0615aea | Rust | ifletsomeclaire/image_processor | /editor_utils/src/gif.rs | UTF-8 | 593 | 2.78125 | 3 | [] | no_license | use std::path::Path;
use gif::{Encoder, Frame, Repeat};
use raster::Image;
// TODO: figure out how to make it work with transparent images?
pub fn generate_gif<P: AsRef<Path>>(path: P, images: Vec<Image>, w: i32, h: i32) {
let mut gif = std::fs::File::create(&path).unwrap();
let mut encoder = Encoder::new(&mut... | true |
89850bc0663914ea82e8c6da16e4e806a3f6f694 | Rust | kkress/adventofcode-2015 | /20/src/main.rs | UTF-8 | 1,754 | 3.671875 | 4 | [
"MIT"
] | permissive | fn all_factors(num: usize) -> Vec<usize> {
let ceiling = (num as f64).sqrt() as usize;
let mut factors = Vec::new();
for curr in 1..num + 1 {
if num % curr == 0 {
let div = num / curr;
if div > curr {
factors.push(curr);
factors.push(div);
... | true |
62d0acb8829b3e1158e5ccd86fd9d9473bb64d04 | Rust | lePerdu/twisted | /src/coord/parity.rs | UTF-8 | 1,861 | 3.40625 | 3 | [
"MIT"
] | permissive | //! Helper functions for defining coordinates defined by a set of identical, independent values with
//! a whole-puzzle parity.
use num_traits::PrimInt;
use crate::util::EnumIndex;
/// Calculates a coordinate from a set of independent values, all in the range from `[0, base)`.
///
/// It is assumed that the whole pu... | true |
7dd3d019445a3e8b42f81a8c230addcb0d048ced | Rust | liushuyu/modern-paste-rs | /src/config.rs | UTF-8 | 825 | 2.59375 | 3 | [] | no_license | use serde_derive::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Config {
#[serde(rename = "BUILD_ENVIRONMENT")]
build_environment: String,
#[serde(rename = "ENABLE_PASTE_ATTACHMENTS")]
allow_attachments: bool,
#[serde(rename = "MAX_ATTACHMENT_SIZE")]
max_attachment_size... | true |
c7cb9ae7d8245062dbdf41422d98de787b6ac6aa | Rust | stevelorenz/programming-playground | /language/rust/programming_rust/fern_sim/tests/unfurl.rs | UTF-8 | 805 | 2.640625 | 3 | [] | no_license | #![allow(unused_imports, dead_code)]
use fern_sim::Terrarium;
use std::time::Duration;
#[test]
// Let the compiler allow us to do things that can statically prove will be panic!
// This feature is used to test code that should be panic!
#[allow(unconditional_panic)]
#[should_panic(expected = "divide by zero")]
fn dum... | true |
eb03ea1aa7f099f8a09152ace157ca96a99c2f65 | Rust | chux0519/leetcode-rust | /archived/q026_remove_duplicates_from_sorted_array.rs | UTF-8 | 796 | 3.375 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
if nums.len() == 0 || nums.len() == 1 {
return nums.len() as i32;
}
let (mut i, mut j) = (0, 1);
while i < nums.len() && j < nums.len() {
if nums[i] != nums[j] {
... | true |
55d88adbe68cf48d407d091546868f2bae597376 | Rust | kabiiQ/dynamic_dns_cloudflare | /src/main.rs | UTF-8 | 2,277 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use crate::cloudflare::Cloudflare;
use crate::ip::IPLookup;
use std::thread;
use std::time::Duration;
use std::io::Read;
mod config;
mod cloudflare;
mod ip;
fn main() {
if let Err(err_str) = application() {
// keep console open on error
eprintln!("Error: {}", err_str);
println!("Press retu... | true |
a22b9f499973aeb8597955899413f77a2d16ca0c | Rust | andete/atsam4lc8c | /src/aesa/mode/mod.rs | UTF-8 | 8,525 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | 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::MODE {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
91415169a261286a4cdf7b42b1e4579bdc6612a4 | Rust | silveirinhajr1233/Projecto-Integrado | /PerfectNumbers/src/main.rs | UTF-8 | 771 | 4.03125 | 4 | [] | no_license | fn main ( ) {
fn factor_sum(n: i32) -> i32 {
let mut v = Vec::new(); //criar um novo array vazio
for x in 1..n-1 { //testa valores desde 1 a n-1
if n%x == 0 { //se x é divisivel por n
v.push(x); //adiciona x ao array
}
}
le... | true |
97093b47f274c5710ddac3d4b554b95987f171b6 | Rust | fortime/sql-permutation | /src/arg.rs | UTF-8 | 2,493 | 2.75 | 3 | [] | no_license | use clap::{Arg, ArgMatches};
pub const LOG_CONFIG_FILE: &'static str = "log-config-file";
pub const CLUSTERS: &'static str = "clusters";
pub const SQL_FILES: &'static str = "sql-files";
pub const INIT_SQL_FILE: &'static str = "init-sql-file";
pub const RESET_SQL_FILE: &'static str = "reset-sql-file";
pub const TIDB_D... | true |
0933f3257402c1efdf0ae0ecccad01cc1a3e2dd8 | Rust | arnau/blot | /blot-lib/src/uvar.rs | UTF-8 | 5,560 | 3.171875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2018 Arnau Siches
//
// Licensed under the MIT license <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to
// those terms.
//! Uvar is an implementation of unsigned variable integers.
//!
//! https://github.com/multiformats/unsigned... | true |
7acf1f946d498f6c23011b885a70f0b62e43e8b5 | Rust | 196Ikuchil/nes_emulator | /src/nes/cpu_register/mod.rs | UTF-8 | 8,870 | 3.078125 | 3 | [
"MIT"
] | permissive | use super::helper::*;
use super::types::{Data, Addr, Word};
#[derive(Debug)]
struct Status {
negative: bool,
overflow: bool,
reserved: bool, // non usable, always true
break_mode: bool,
decimal_mode: bool, // non usable on nes
interrupt: bool, // interrupt disable flag
zero: bool,
carry: bool,
}
#[all... | true |
c7993cc3c10bb03f90c9c35f6d27e8266add3a77 | Rust | Nugine/bpnn-rs | /src/main.rs | UTF-8 | 1,165 | 2.703125 | 3 | [] | no_license | mod bpnn;
fn main() {
demo::run();
}
mod demo {
use crate::bpnn::*;
use ndarray::array;
use std::iter::FromIterator;
pub fn run() {
let layer_settings: Vec<(usize, Activation, DActivation)> = vec![
(3, tanh, d_tanh),
(2, sigmoid, d_sigmoid),
(1, relu, d... | true |
73173f2eceacc17e4d738a13445955450a6460c1 | Rust | rodrimati1992/abi_stable_crates | /abi_stable/src/misc_tests/impl_interfacetype_macro.rs | UTF-8 | 9,504 | 2.59375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::{fmt::Debug, marker::PhantomData};
use crate::{
impl_InterfaceType,
type_level::{
bools::{False, True},
impl_enum::{Implemented, Unimplemented},
},
GetStaticEquivalent, InterfaceType, StableAbi,
};
use core_extensions::type_asserts::AssertEq;
#[repr(C)]
#[derive(StableAbi)]
p... | true |
d49c39bbe2062644f19e2aa0599a1e5b69e6065f | Rust | csmr/random-dev-notes | /rust-src-for-codingame.rs | UTF-8 | 1,524 | 2.8125 | 3 | [
"MIT"
] | permissive | // solution for as cii art
use std::io;
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
fn main() {
//let mut input_line = String::new();
//io::... | true |
a4bbc5a3d6fc3d2eeb75ba6a6b4f7e0f6bf4444e | Rust | JeanCASPAR/challenges | /defi08/rust/jean/src/game.rs | UTF-8 | 6,776 | 2.703125 | 3 | [] | no_license | use bevy::prelude::*;
use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) enum TokenColor {
Red,
Yellow,
Black,
}
pub(crate) struct Winner(pub TokenColor);
pub(crate) enum GameTurn {
Player1,
Player2,
}
pub(crate) struct GameBoard([[Entity; 6]; 7]);
/// Between 0 and 6,... | true |
2e54d9be05939eedeed84111d6c697a50eb87e24 | Rust | svenschmidt75/Rust | /DSandAlg/CodingProblems/ClimbingStairs/src/lib.rs | UTF-8 | 2,171 | 3.421875 | 3 | [] | no_license | fn climb_stairs(n: i64) -> u64 {
// SS: terrible runtime performance, O(2^n), due to the two branches
if n == 0 {
0
} else {
let mut solutions = 0;
climb_stairs_internal(n, &mut solutions);
solutions
}
}
fn climb_stairs_internal(n: i64, solutions: &mut u64) {
if n ==... | true |
c9cab4d2f377399be3b142c2b61745e6aa865943 | Rust | qryxip/mic | /tests/recursion.rs | UTF-8 | 570 | 2.828125 | 3 | [
"CC0-1.0"
] | permissive | use mic::{answer, solve};
use std::sync::atomic::{self, AtomicBool};
#[test]
fn answer() {
let _: () = main();
#[answer]
fn main() -> &'static str {
return if VISITED.swap(true, atomic::Ordering::SeqCst) {
""
} else {
main()
};
static VISITED: Atomic... | true |
51f9562037d5919552bbb4a6d35355cf986ea262 | Rust | JoelAtDeluxe/AdventOfCode2015-rust | /day14/src/lib.rs | UTF-8 | 2,856 | 3.5 | 4 | [] | no_license |
#[derive(Debug)]
pub struct Deer {
pub name: String,
rate: i32,
sprint_duration: i32,
sleep_duration: i32
}
impl Deer {
pub fn new(name: &str, rate: i32, sprint_duration: i32, sleep_duration: i32) -> Deer {
Deer{name: String::from(name), rate, sprint_duration, sleep_duration}
}
}
fn ... | true |
5dc6d8ca663745da1365ecf280f8adb7e23c2bda | Rust | marceljay/rust_playground | /src/structs.rs | UTF-8 | 3,712 | 3.90625 | 4 | [] | no_license | // Structs can be used to create custom data types
// There are regular structs and tuple structs with unnamed fields
// must be located in a sub-folder
mod other_struct;
use other_struct::NameTrait;
use other_struct::*; // allows me to omit 'namespace::struct'
mod other_trait;
use other_trait::*; // without use trai... | true |
7f62b4d4992f7f198d53a2f59416a7862d42806d | Rust | jmou/aoc2018 | /d01/src/bin/p2.rs | UTF-8 | 422 | 2.984375 | 3 | [] | no_license | use std::collections::HashSet;
use std::io::{self, BufRead};
fn main() {
let numbers = io::stdin()
.lock()
.lines()
.map(|x| x.unwrap().parse().unwrap())
.collect::<Vec<_>>();
let mut seen = HashSet::new();
let mut sum = 0;
for num in numbers.iter().cycle() {
if ... | true |
1ab650a0ff7cc040753259735fb7d30c70411886 | Rust | OctoD/salvicli | /src/commands/a_casa_loro/mod.rs | UTF-8 | 398 | 2.75 | 3 | [] | no_license | use std::fs::rename;
use std::io::{
Error,
ErrorKind,
};
use std::result::Result;
use clap::{
Values,
};
pub fn run(values: Values) -> Result<(), Error> {
let mut c = values;
let origin = c.nth(0);
let destination = c.nth(1);
if origin.and(destination).is_some() {
rename(origin.unwrap(), destination... | true |
14bf11a2ee167b4c6590595f3b0b5d504276c0d2 | Rust | CM-Tech/conway | /src/main.rs | UTF-8 | 3,024 | 3.15625 | 3 | [] | no_license | use std::{thread, io};
use std::io::BufRead;
use std::{cmp, fmt};
use std::time::Duration;
const MAP_WIDTH: usize = 40;
const MAP_HEIGHT: usize = 30;
struct Conway {
map: [[bool; MAP_WIDTH]; MAP_HEIGHT],
}
impl Conway {
fn new(pattern: Vec<&'static str>) -> Conway {
let mut map = [[false; MAP_WIDTH];... | true |
f2d29e496567669b2c2fd0874d2f8d0e9e068e6a | Rust | dsnam/LocustDB | /src/engine/vector_op/merge_aggregate.rs | UTF-8 | 2,289 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use engine::aggregator::Aggregator;
use engine::typed_vec::MergeOp;
use engine::vector_op::*;
use engine::*;
#[derive(Debug)]
pub struct MergeAggregate {
pub merge_ops: BufferRef,
pub left: BufferRef,
pub right: BufferRef,
pub aggregated: BufferRef,
pub aggregator: Aggregator,
}
impl<'a> VecOpera... | true |
65e27a6a415feefc97b45628e3f4e31bfe690cfb | Rust | awsomearvinder/craps | /src/main.rs | UTF-8 | 1,630 | 3.28125 | 3 | [] | no_license | use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
fn roll2die<T: Rng>(mut rng: T) -> (i32, i32) {
let first_roll = rng.gen_range(1, 7);
let second_roll = rng.gen_range(1, 7);
(first_roll, second_roll)
}
fn main() {
let mut thread_rng = SmallRng::seed_from_u64(1);
let mut string = String::with_... | true |
80329c519e4750ae513b1ed29de7eb09c20887f3 | Rust | mkihr-ojisan/html-extractor | /html-extractor/src/lib.rs | UTF-8 | 13,189 | 3.75 | 4 | [
"MIT"
] | permissive | #![allow(clippy::needless_doctest_main)]
//! This crate provides an easy way to extract data from HTML.
//!
//! [`HtmlExtractor`] is neither a parser nor a deserializer.
//! It picks up only the desired data from HTML.
//!
//! [`html_extractor!`](macro.html_extractor.html) will help to implement [`HtmlExtractor`].
//!
... | true |
c12375c6d58635c0f77c4100ab0c542402ba67d3 | Rust | rust-windowing/winit | /src/platform/web.rs | UTF-8 | 5,281 | 3.390625 | 3 | [
"Apache-2.0"
] | permissive | //! The web target does not automatically insert the canvas element object into the web page, to
//! allow end users to determine how the page should be laid out. Use the [`WindowExtWebSys`] trait
//! to retrieve the canvas from the Window. Alternatively, use the [`WindowBuilderExtWebSys`] trait
//! to provide your own... | true |
1fddbad28a561ee886da1e88b0ef18a8b2be13b5 | Rust | TheNeikos/azure-iot-sdk-rs | /src/http_transport.rs | UTF-8 | 4,597 | 2.703125 | 3 | [
"MIT"
] | permissive | #[cfg(feature = "direct-methods")]
use crate::message::DirectMethodResponse;
use crate::message::Message;
#[cfg(any(
feature = "direct-methods",
feature = "c2d-messages",
feature = "twin-properties"
))]
use crate::message::MessageType;
use crate::{token::{TokenProvider, TokenSource}, transport::Transport};
... | true |
a8948e575f7cc6acd09974689a72e078d77b8602 | Rust | therealprof/mkw41z | /src/ftfa/facsn/mod.rs | UTF-8 | 2,146 | 2.796875 | 3 | [
"BSD-3-Clause",
"0BSD"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u8,
}
impl super::FACSN {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = "Possible values of the field `NUMSG`"]
#[derive(Clone... | true |
c606b8ee17619dc8284e5750a9b1cef9ff6e402e | Rust | richardpringle/advent-rust | /problem-12/src/main.rs | UTF-8 | 5,672 | 3.265625 | 3 | [] | no_license | use std::{error::Error, fs};
use regex::Regex;
#[derive(Copy, Clone, Debug, PartialEq)]
struct Vec3 {
x: i32,
y: i32,
z: i32,
}
impl Vec3 {
fn zero() -> Self {
Vec3 { x: 0, y: 0, z: 0 }
}
fn apply_gravity(&self, other: &Self) -> Self {
let x = match self.x {
x if x... | true |
d21d5e2e7681863cce7535715d13dd8b594d59d1 | Rust | Disasm/wasm-workshop | /forth/src/lib.rs | UTF-8 | 1,204 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate cfg_if;
extern crate wasm_bindgen;
mod utils;
use cfg_if::cfg_if;
use wasm_bindgen::prelude::*;
cfg_if! {
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
if #[cfg(feature = "wee_alloc")] {
extern crate wee_alloc;
#[global_allocator]
... | true |
8f66745b187ffc7a27409e6badd7077abc54dc9e | Rust | bergercookie/cargo-asm | /src/target.rs | UTF-8 | 5,701 | 2.859375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::options::*;
use log::{debug, error};
use serde_derive::Deserialize;
use std::io::prelude::*;
pub struct TargetInfo {
triple: String,
}
impl Default for TargetInfo {
fn default() -> Self {
TargetInfo {
triple: "none-none-none".to_owned(),
}
}
}
impl TargetInfo {
... | true |
f689771e3557ebd3fb135de93486f317e714bae8 | Rust | jamesmarva/The-Rust-Programming-Language | /code/ch17/code_17_5/src/main.rs | UTF-8 | 287 | 2.515625 | 3 | [] | no_license |
pub trait Draw {
fn draw(&self);
}
pub struct Screen {
components: Vec<Box<dyn Draw>>,
}
impl Screen {
pub fn run (&self) {
for c in self.components.iter() {
println!("待写");
c.draw();
}
}
}
fn main() {
}
| true |
42ca3e54935ad8769921e7de92e2d4179453f8a7 | Rust | mati865/home | /src/windows.rs | UTF-8 | 4,201 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![cfg(windows)]
use std::env;
use std::ffi::OsString;
use std::io;
use std::os::windows::ffi::OsStringExt;
use std::path::PathBuf;
use std::ptr;
use winapi::shared::minwindef::DWORD;
use winapi::shared::winerror::ERROR_INSUFFICIENT_BUFFER;
use winapi::um::errhandlingapi::{GetLastError, SetLastError};
use winapi::um:... | true |
e4a59d3bc602bd9622472fe7250d7109889b3a3a | Rust | emmanuel-h/AdventOfCode2020 | /src/day_04.rs | UTF-8 | 1,907 | 3.046875 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
#[derive(Debug)]
struct Passport {
byr: bool,
iyr: bool,
eyr: bool,
hgt: bool,
hcl: bool,
ecl: bool,
pid: bool,
cid: bool,
}
impl Passport {
fn valid(&self) -> bool {
self.byr && self.iyr && self.eyr && self.hgt && self.... | true |
fcd153ab7972415620840386ed44820824e7a788 | Rust | skrytt/baselisk-rs | /core/src/engine/generator.rs | UTF-8 | 10,966 | 2.703125 | 3 | [
"MIT"
] | permissive | use defs;
use engine::{
pitch_bend,
traits,
};
use shared::{
event::EngineEvent,
parameter::{
BaseliskPluginParameters,
ParameterId,
},
};
use std::slice;
/// Convert a note number to a corresponding frequency,
/// using 440 Hz as the pitch of the A above middle C.
fn get_frequency(... | true |
4eb70ddcbc3d41555b7f89a4f144b39c34650538 | Rust | cijber/reex | /reex-vm/src/lib.rs | UTF-8 | 4,180 | 3.046875 | 3 | [] | no_license | use std::fmt;
use std::fmt::{Display, Formatter};
use std::str::Chars;
use std::sync::Arc;
use unicode_segmentation::GraphemeCursor;
pub mod matchers;
pub mod vm;
#[derive(Clone, Debug)]
enum ReexInnerString {
Static(&'static str),
Dynamic(Arc<String>),
}
impl PartialEq for ReexInnerString {
fn eq(&self,... | true |
bb0a5daa9d7304f7dac6c7a46151dd90181620c4 | Rust | rnbguy/uosql-server | /server/src/parse/parser.rs | UTF-8 | 41,457 | 3.203125 | 3 | [
"MIT"
] | permissive | use super::super::storage::SqlType;
use super::ast::*;
use super::lex;
use super::lex::Lexer;
use super::token::Token;
use super::token::{Lit, TokenSpan};
use super::Span;
use std::collections::HashMap;
/// Program for testing and playing with the parser
///
use std::iter::Iterator;
use std::mem::swap;
// ===========... | true |
a18daec7e8afe04893b70a21861994dc35b0420d | Rust | dai1975/fiatproof | /src/bitcoin/protocol/message/pong_message.rs | UTF-8 | 1,542 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use std;
use super::PingMessage;
#[derive(Debug,Default,Clone)]
pub struct PongMessage
{
pub nonce: u64,
}
use super::message::{ Message, COMMAND_LENGTH };
impl Message for PongMessage {
const COMMAND:[u8; COMMAND_LENGTH] = [0x70, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
}
impl std::f... | true |
77d1c2d894662dd935f908b46d57ac2d71e9bcbb | Rust | APiercey/mylalang | /src/core/eval_test.rs | UTF-8 | 397 | 2.671875 | 3 | [] | no_license | mod common;
use common::assert_eq;
use myla::core::types::Types::{Bool, Float, Integer, Nil, String as Str};
#[test]
fn test_evaluating_values() {
assert_eq(
r#"(eval "(def a 1)")
(inspect a)"#,
Integer(1),
);
}
#[test]
fn test_evaluating_functions() {
assert_eq(
r#"(eval "... | true |
2492b1ee463dd208fe216ec0809c68dd73a06326 | Rust | ricmzn/dcs-hemmecs | /src/installer/mod.rs | UTF-8 | 2,814 | 2.890625 | 3 | [
"MIT"
] | permissive | mod constants;
mod utils;
use std::{
fs::{create_dir_all, remove_file, File},
io::{Read, Write},
path::{Path, PathBuf},
};
use anyhow::{Context, Result};
pub enum DCSVersion {
Stable,
Openbeta,
}
pub enum InstallStatus {
DCSNotFound,
NotInstalled,
RequiresUpdate,
Installed,
}
im... | true |
54cc2434b56ebef15b4d4a7ecf01c069e3ee6ea0 | Rust | farrel/GTNW | /src/main.rs | UTF-8 | 920 | 2.5625 | 3 | [] | no_license | #![feature(globs)]
extern crate ncurses;
use ncurses::*;
use display::Display;
use status_bar::StatusBar;
use command_window::CommandWindow;
mod command_window;
mod display;
mod status_bar;
fn initialise_ncurses() {
initscr();
//ncurses::noecho();
}
fn main() {
initialise_ncurses();
/* Get the scre... | true |
726b0287d21f52bd67dabd7246db64180b8e83b5 | Rust | mesalock-linux/quickcheck-sgx | /benches/tuples.rs | UTF-8 | 3,483 | 2.53125 | 3 | [
"MIT",
"Unlicense"
] | permissive | #![feature(test)]
extern crate quickcheck;
extern crate rand;
extern crate test;
use quickcheck::{Arbitrary, StdGen};
use rand::prng::hc128::Hc128Rng;
use rand::SeedableRng;
use test::Bencher;
macro_rules! bench_shrink {
($(($fn_name:ident, $type:ty),)*) => {
$(
#[bench]
fn $fn_na... | true |
84f55aa3bbc433f30aa93f8004fad9c5fa46a444 | Rust | jt-l/stocks | /src/db.rs | UTF-8 | 3,434 | 3.125 | 3 | [
"MIT"
] | permissive | extern crate rusqlite;
use std::env;
use rusqlite::types::ToSql;
use rusqlite::NO_PARAMS;
use rusqlite::{Connection, Result};
use crate::Config;
use crate::Command;
use crate::api;
use crate::formatter;
// enum of available queries
pub enum Queries {
GetStocks,
InsertStock,
RemoveStock,
CreateTab... | true |
b1ae88d22b2699609418e36b5f3469c6db2a7bd4 | Rust | birtles/jmdict-couch | /src/main.rs | UTF-8 | 20,904 | 2.515625 | 3 | [] | no_license | #[macro_use]
extern crate failure;
extern crate memchr;
extern crate quick_xml;
extern crate smallvec;
#[macro_use]
extern crate structopt;
use failure::{Error, ResultExt};
use smallvec::SmallVec;
use std::path::PathBuf;
use std::str;
use std::str::FromStr;
use structopt::StructOpt;
use quick_xml::reader::Reader;
use ... | true |
1501e86ae33bddb4b5b6db84da23518b4d55af65 | Rust | Tmw/programming-challanges | /advent-of-code-2016/day_2/src/main.rs | UTF-8 | 6,497 | 3.46875 | 3 | [
"MIT"
] | permissive | /*
--- Day 2: Bathroom Security ---
You arrive at Easter Bunny Headquarters under cover of darkness. However, you left in such a rush that you forgot to use the bathroom! Fancy office buildings like this one usually have keypad locks on their bathrooms, so you search the front desk for the code.
"In order to improve ... | true |
bc0bd0405eff7159d60d15fd32415b1c585dc6a7 | Rust | It4innovations/hyperqueue | /crates/tako/src/internal/messages/common.rs | UTF-8 | 612 | 2.578125 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct TaskFailInfo {
pub message: String,
/* #[serde(default)]
#[serde(skip_serializing_if = "String::is_empty")]*/
pub data_type: String,
#[serde(with = "serde_bytes")]
/* #[serde(default)]
#[serde(s... | true |
6e4f9eac1e9657cf8de4c72024388e0e12058678 | Rust | ysenko/Chip8VM-wasm-poc | /tests/web.rs | UTF-8 | 1,097 | 2.75 | 3 | [
"MIT"
] | permissive | //! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
extern crate wasm_bindgen_test;
use chip8_wasm::new_vm;
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
fn test_get_display_size() {
let vm = new_vm();
assert_eq!(128, vm.get_displ... | true |
b37596ed7e91c09b4427accb19c244a9a6b4b6ea | Rust | mikrostew/advent-of-code | /2022/src/day19.rs | UTF-8 | 14,180 | 2.671875 | 3 | [] | no_license | use std::cmp::{max, min};
use nom::bytes::complete::tag;
use nom::character::complete::multispace1;
use nom::character::complete::newline;
use nom::combinator::map;
use nom::multi::many1;
use nom::multi::separated_list1;
use nom::sequence::delimited;
use nom::sequence::terminated;
use nom::sequence::tuple;
use nom::IR... | true |
6953a9029c9a0e3a46d94f53d6872a281fb2b6d5 | Rust | abhyuditjain/aoc2020 | /src/day7.rs | UTF-8 | 3,898 | 3.078125 | 3 | [] | no_license | use std::collections::{HashMap, VecDeque};
use aoc_runner_derive::{aoc, aoc_generator};
use lazy_static::lazy_static;
use regex::Regex;
const GOAL: &str = "shiny gold";
lazy_static! {
static ref LINE_RE: Regex = Regex::new(r"(\w+ \w+) bags contain (.*)").unwrap();
static ref ITEM_RE: Regex = Regex::new(r"(\d+... | true |
23cd6d89a07378e5d136d202c435ada72f21ea37 | Rust | Forlos/vndb_rs | /src/common/get/producer.rs | UTF-8 | 1,465 | 2.609375 | 3 | [
"Unlicense"
] | permissive | use super::GetFlag;
use super::{GetFlag::*, Results};
use serde::Deserialize;
/// All valid flags for get producer method
pub const PRODUCER_FLAGS: [GetFlag; 3] = [Basic, Details, Relations];
/// Results returned from get producer method
#[derive(Deserialize, Debug, PartialEq)]
pub struct GetProducerResults {
#[s... | true |
36e19d840302feb328787f6a74039b5f78c2105e | Rust | tweag/nickel | /core/src/eval/cache/mod.rs | UTF-8 | 3,782 | 3.015625 | 3 | [
"MIT"
] | permissive | /// The Nickel generic evaluation cache. This module abstracts away the details for managing
/// suspended computations and their memoization strategies.
///
/// Terminology:
/// An *element* of the cache is what is stored inside of it.
/// An *index* into the cache points to a given element.
use super::{Closure, Envir... | true |
65e5893495210f71ae0fee8bfb572a2de476fef3 | Rust | shaneutt/kube-rs | /kube-client/src/api/core_methods.rs | UTF-8 | 23,422 | 2.953125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use either::Either;
use futures::Stream;
use serde::{de::DeserializeOwned, Serialize};
use std::fmt::Debug;
use crate::{api::Api, Error, Result};
use kube_core::{
metadata::PartialObjectMeta, object::ObjectList, params::*, response::Status, ErrorResponse, WatchEvent,
};
/// PUSH/PUT/POST/GET abstractions
impl<K> ... | true |
127d4d382ce6aab929c3ea63e62c1d190619d359 | Rust | pierd/advent-of-code-2018 | /src/bin/day03a.rs | UTF-8 | 4,312 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use std::io::{self, Read};
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct Range(usize, usize, usize);
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
struct Rect(Range, Range, usize);
#[derive(Debug)]
enum RangeSweep<'a> {
On(&'a Range),
Off(&'a Range... | true |
598759c3192ceb4da4bff5dfcaf927c26fbbfd30 | Rust | pola-rs/polars | /crates/polars/tests/it/time/date_range.rs | UTF-8 | 1,899 | 2.75 | 3 | [
"MIT"
] | permissive | use polars::export::chrono::NaiveDate;
use polars::prelude::*;
use polars::time::{date_range, ClosedWindow, Duration};
#[test]
fn test_time_units_9413() {
let start = NaiveDate::from_ymd_opt(2022, 1, 1)
.unwrap()
.and_hms_opt(0, 0, 0)
.unwrap();
let stop = NaiveDate::from_ymd_opt(2022, ... | true |
3a7a75067a88b9a1ed298643c0c709eaad0fb510 | Rust | y-tsuzaki/LearnRust | /list_10_5/src/main.rs | UTF-8 | 350 | 3.59375 | 4 | [] | no_license | fn main() {
println!("Hello, world!");
let v = vec![1,2,3,3,4,5,6];
let result = largest(&v);
println!("largest : {}", result);
}
fn largest<T:PartialOrd + Copy>(list: &[T]) -> T {
let mut largest = list[0];
for &item in list.iter() {
if item > largest {
largest = item;
... | true |
9b1ca9c4cd97ac09feed3d2e2dc71952fff832c3 | Rust | domain-independent-dp/didp-rs | /dypdl/src/grounded_condition.rs | UTF-8 | 26,414 | 3.3125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::expression::*;
use crate::state::StateInterface;
use crate::table_registry;
/// Condition with element parameters.
#[derive(Debug, PartialEq, Clone, Default)]
pub struct GroundedCondition {
/// Pairs of an index of a set variable and a parameter.
/// The condition is evaluated only when all paramete... | true |
cf2ea7a832a06cc785d4987dc2648eee2fd7876d | Rust | alianse777/darknet-rust | /src/network.rs | UTF-8 | 5,399 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::{
detections::Detections,
error::Error,
image::IntoCowImage,
layers::{Layer, Layers},
utils,
};
use darknet_sys as sys;
use std::{
ffi::c_void,
os::raw::c_int,
path::Path,
ptr::{self, NonNull},
slice,
};
/// The network wrapper type for Darknet.
pub struct Network {
... | true |
553bdc85763b6d5e595751d30eee77eb508d0bd9 | Rust | flattiverse/connector-rust | /src/universe.rs | UTF-8 | 6,293 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::error::GameError;
use crate::network::connection_handle::{ConnectionHandle, SendQueryError};
use crate::network::query::{QueryCommand, QueryError, QueryResult};
use crate::region::{GameRegion, GameRegionId};
use crate::team::TeamId;
use serde_derive::{Deserialize, Serialize};
use std::fmt::{Debug, Formatter}... | true |
eac3397c19d1858563c407a957ac9ea6f97d1e1f | Rust | kalleakerblom/AdventOfCode2019 | /src/day6.rs | UTF-8 | 2,319 | 3.390625 | 3 | [] | no_license | use std::collections::HashMap;
fn calculate_orbits(orbits: &[&str], start: &str, end: &str) -> (u32, u32) {
let mut orbit_map = HashMap::new();
for orb in orbits {
let split: Vec<&str> = orb.split(')').collect();
let (parent, child) = (split[0], split[1]);
orbit_map.insert(child, parent)... | true |
9ffc82c003f3d754c82d458358336e59c8079017 | Rust | jpJuni0r/WebGrid | /core/build.rs | UTF-8 | 3,833 | 2.609375 | 3 | [
"MIT",
"AGPL-3.0-only"
] | permissive | use git2::{DescribeFormatOptions, DescribeOptions, Repository};
use serde::Deserialize;
use sqlx::{Connection, SqliteConnection};
use std::env;
use std::fs::{read_to_string, remove_file, File};
use std::io::prelude::*;
use std::path::PathBuf;
use std::{collections::HashMap, str::FromStr};
// use vergen::{vergen, Config... | true |
2c56d6a7f73146706b9a03f26445b75a3e3e57e0 | Rust | SymmetricChaos/project_euler_rust | /src/worked_problems/euler_18.rs | UTF-8 | 2,524 | 3.296875 | 3 | [] | no_license | // Find the maximum total from top to bottom of the triangle below:
/*
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17... | true |
834b23f57e9552ce265fd42bc53cfa12973e5117 | Rust | iCodeIN/syscall | /syscall-rs/examples/file.rs | UTF-8 | 754 | 3.15625 | 3 | [] | no_license | use std::path::Path;
use syscall_rs::{types::fd::FileDescriptor, file::{close, open}, io::read};
fn main() -> Result<(), std::io::Error> {
// Make a path to our favorite file
let path = Path::new("examples/files/hello_world.txt");
// Open it, and get a file descriptor
let fd = open(&path, 0, 0)?;
... | true |
46910176d6a10f317fccce6342a289f57c18c0a4 | Rust | Vypo/vented | /src/lib.rs | UTF-8 | 1,335 | 3 | 3 | [] | no_license | #[macro_use]
extern crate cfg_if;
cfg_if! {
if #[cfg(unix)] {
extern crate nix;
extern crate xdg;
} else if #[cfg(windows)] {
extern crate winapi;
}
}
pub mod error;
mod platform;
use error::*;
pub use platform::{Receiver, Sender};
use std::path::Path;
/// Attempts to prevent p... | true |
6b3cdbc78368d00a441700d7cd51854c97d1ccfb | Rust | SleepPerformer/easybuffers | /examples/test_none.rs | UTF-8 | 10,818 | 2.796875 | 3 | [] | no_license | #[macro_use]
extern crate easybuffers;
extern crate time;
use easybuffers::helper::{ Table, HyperHelper };
#[derive(PartialEq,Clone,Default,Debug)]
pub struct TestMessage {
field_0: Option<String>,
field_1: Option<String>, // 1
field_2: Option<bool>, // 2
field_3: bool, // 4
field_4: String, // 1
... | true |
c754b49799c741aa56f79493ae5f305497249208 | Rust | unkillable/Rust-Simple-IRC-Bot | /rust.rs | UTF-8 | 1,893 | 2.859375 | 3 | [] | no_license | use std::io::TcpStream;
use std::io::BufferedStream;
fn main() {
let nick = "RustBOT";
let channel = "#mootsinsuits";
let nick_packet = format!("NICK {}\r\n", nick);
let user_packet = format!("USER {} {} {} :{}\r\n", nick, nick, nick, nick);
let join_packet = format!("JOIN {}\r\n", channel);
let mut socket = Buff... | true |
81606866c39ddd5e2904e0b44b76845e58d7b98e | Rust | darfink/chakracore-rs | /chakracore/src/value/number.rs | UTF-8 | 1,152 | 3.15625 | 3 | [] | no_license | use crate::{value::Value, ContextGuard};
use chakracore_sys::*;
/// A JavaScript number.
pub struct Number(JsValueRef);
impl Number {
/// Creates a new number.
pub fn new(_guard: &ContextGuard, number: i32) -> Self {
let mut value = JsValueRef::new();
unsafe {
jsassert!(JsIntToNumber(number, &mut va... | true |
cfaaf1bb48bed0ae1a348a27c1c2ddb00c1304f0 | Rust | mariszo/logram | /src/config/mod.rs | UTF-8 | 1,099 | 2.671875 | 3 | [
"MIT"
] | permissive | use std::env;
use std::fs::File;
use serde_yaml;
use telegram;
mod error;
pub use self::error::ConfigError;
#[derive(Debug, Deserialize)]
pub struct Config {
pub telegram: TelegramConfig,
pub watcher: WatcherConfig,
}
#[derive(Debug, Deserialize)]
pub struct TelegramConfig {
pub token: String,
pub ch... | true |
9ed8e3786962660c2081944bce5448ce79a96c96 | Rust | hassoon1986/ckb | /util/rational/src/lib.rs | UTF-8 | 9,716 | 3.15625 | 3 | [
"MIT"
] | permissive | #![allow(clippy::suspicious_arithmetic_impl)]
#[cfg(test)]
mod tests;
use numext_fixed_uint::U256;
use std::ops::{Add, Div, Mul, Sub};
#[derive(Clone, Debug)]
pub struct RationalU256 {
/// Numerator.
numer: U256,
/// Denominator.
denom: U256,
}
impl RationalU256 {
#[inline]
pub fn new(numer:... | true |
696d6777063706795c99e49b09f09063ad55bfc9 | Rust | pnkfelix/pgy_runtime | /src/graph/mod.rs | UTF-8 | 3,288 | 3.15625 | 3 | [] | no_license | use arena::{ArenaMut};
use arena::{ArenaVex, ArenaVexIter};
pub mod gss;
// Values carrying some state uniquely identifying them relative to
// their type.
pub trait Id {
fn id(&self) -> usize;
}
impl<'a, T> Id for &'a Node<'a, T> {
fn id(&self) -> usize {
*self as *const Node<'a, T> as usize
}
}... | true |
267dc1fd6812dfd977cc7598cecd2054a9589090 | Rust | Nercury/di-rs | /examples/bridge.rs | UTF-8 | 1,190 | 3.03125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate di;
use di::Deps;
use std::sync::Arc;
struct Window {
pub resize_listeners: Vec<Box<Fn(i32, i32) + Sync + Send>>,
}
struct Logger {
pub log_fn: Arc<Fn(&str) + Send + Sync>,
}
impl Window {
fn new() -> Window {
Window { resize_listeners: Vec::new() }
}
fn resize(&self, w: i3... | true |
c9dc57cd9731d2f7b9c0182e5730a09758128918 | Rust | krautcat/des-rs | /src/lib.rs | UTF-8 | 15,276 | 3.515625 | 4 | [
"MIT"
] | permissive | //! Data Encryption Standard Rust implementation.
//!
//! The only supported mode is Electronic Codebook (ECB).
//!
//! # Example
//!
//! ```
//! extern crate des_rs_krautcat;
//!
//! let key = [0x13, 0x34, 0x57, 0x79, 0x9B, 0xBC, 0xDF, 0xF1];
//! let message = [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF];
//! let ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.